Rename unifying plugin to logitech-hidpp (Fixes: #1329)

This commit is contained in:
Mario Limonciello 2019-11-01 14:57:48 -05:00 committed by Mario Limonciello
parent 6b0e4ba021
commit 5123d4333e
38 changed files with 540 additions and 540 deletions

View File

@ -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.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_uefi_recovery.so %{_libdir}/fwupd-plugins-3/libfu_plugin_uefi_recovery.so
%endif %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_upower.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_vli_usbhub.so %{_libdir}/fwupd-plugins-3/libfu_plugin_vli_usbhub.so
%{_libdir}/fwupd-plugins-3/libfu_plugin_wacom_raw.so %{_libdir}/fwupd-plugins-3/libfu_plugin_wacom_raw.so

View File

@ -118,13 +118,13 @@ if __name__ == '__main__':
test.add_file('0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7.cab', '2.0.7') test.add_file('0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7.cab', '2.0.7')
tests.append(test) 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 = Test('UnifyingRQR12', '9d131a0c-a606-580f-8eda-80587250b8d6')
test.add_file('6e5ab5961ec4c577bff198ebb465106e979cf686-Logitech-Unifying-RQR12.05_B0028.cab', 'RQR12.05_B0028') 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') test.add_file('938fec082652c603a1cdafde7cd25d76baadc70d-Logitech-Unifying-RQR12.07_B0029.cab', 'RQR12.07_B0029')
tests.append(test) 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 = Test('UnifyingRQR24', 'cc4cbfa9-bf9d-540b-b92b-172ce31013c1')
test.add_file('82b90b2614a9a4d0aced1ab8a4a99e228c95585c-Logitech-Unifying-RQ024.03_B0027.cab', 'RQR24.03_B0027') 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') test.add_file('4511b9b0d123bdbe8a2007233318ab215a59dfe6-Logitech-Unifying-RQR24.05_B0029.cab', 'RQR24.05_B0029')

View File

@ -412,8 +412,8 @@ fu_plugin_update_reload (FuPlugin *plugin, FuDevice *device, GError **error)
set process-wide. set process-wide.
This allows plugins to detect when they should output detailed debugging This allows plugins to detect when they should output detailed debugging
information that would normally be too verbose to keep in the journal. information that would normally be too verbose to keep in the journal.
For example, using <code>--plugin-verbose=unifying</code> would set For example, using <code>--plugin-verbose=logitech_hidpp</code> would set
<code>FWUPD_UNIFYING_VERBOSE=1</code>. <code>FWUPD_LOGITECH_HID_VERBOSE=1</code>.
</para> </para>
</section> </section>

View File

@ -1,4 +1,4 @@
Unifying Support Logitech HID Support
================ ================
Introduction Introduction

View File

@ -8,22 +8,22 @@
#include <string.h> #include <string.h>
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-bootloader-nordic.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 * 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; 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: "); g_prefix_error (error, "failed to get HW ID: ");
return NULL; return NULL;
} }
@ -31,42 +31,42 @@ fu_unifying_bootloader_nordic_get_hw_platform_id (FuUnifyingBootloader *self, GE
} }
static gchar * 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; 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; 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: "); g_prefix_error (error, "failed to get firmware version: ");
return NULL; return NULL;
} }
/* RRRxx.yy_Bzzzz /* RRRxx.yy_Bzzzz
* 012345678901234*/ * 012345678901234*/
micro = (guint16) fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 10) << 8; micro = (guint16) fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 10) << 8;
micro += fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 12); micro += fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 12);
return fu_unifying_format_version ("RQR", return fu_logitech_hidpp_format_version ("RQR",
fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 3), fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 3),
fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 6), fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 6),
micro); micro);
} }
static gboolean 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 *hw_platform_id = NULL;
g_autofree gchar *version_fw = NULL; g_autofree gchar *version_fw = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
/* get MCU */ /* 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) if (hw_platform_id == NULL)
return FALSE; return FALSE;
g_debug ("hw-platform-id=%s", hw_platform_id); g_debug ("hw-platform-id=%s", hw_platform_id);
/* get firmware version, which is not fatal */ /* 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) { if (version_fw == NULL) {
g_warning ("failed to get firmware version: %s", g_warning ("failed to get firmware version: %s",
error_local->message); error_local->message);
@ -81,16 +81,16 @@ fu_unifying_bootloader_nordic_setup (FuUnifyingBootloader *self, GError **error)
} }
static gboolean 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, guint16 addr, guint8 len, const guint8 *data,
GError **error) 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->cmd = 0xC0;
req->addr = addr; req->addr = addr;
req->len = len; req->len = len;
memcpy (req->data, data, req->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); g_prefix_error (error, "failed to write sig @0x%02x: ", addr);
return FALSE; return FALSE;
} }
@ -106,11 +106,11 @@ fu_unifying_bootloader_nordic_write_signature (FuUnifyingBootloader *self,
} }
static gboolean static gboolean
fu_unifying_bootloader_nordic_write (FuUnifyingBootloader *self, fu_logitech_hidpp_bootloader_nordic_write (FuLogitechHidPpBootloader *self,
guint16 addr, guint8 len, const guint8 *data, guint16 addr, guint8 len, const guint8 *data,
GError **error) 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->cmd = FU_UNIFYING_BOOTLOADER_CMD_WRITE;
req->addr = addr; req->addr = addr;
req->len = len; req->len = len;
@ -123,7 +123,7 @@ fu_unifying_bootloader_nordic_write (FuUnifyingBootloader *self,
return FALSE; return FALSE;
} }
memcpy (req->data, data, req->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 transfer fw @0x%02x: ", addr); g_prefix_error (error, "failed to transfer fw @0x%02x: ", addr);
return FALSE; return FALSE;
} }
@ -165,13 +165,13 @@ fu_unifying_bootloader_nordic_write (FuUnifyingBootloader *self,
} }
static gboolean 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->cmd = FU_UNIFYING_BOOTLOADER_CMD_ERASE_PAGE;
req->addr = addr; req->addr = addr;
req->len = 0x01; 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); g_prefix_error (error, "failed to erase fw @0x%02x: ", addr);
return FALSE; return FALSE;
} }
@ -195,13 +195,13 @@ fu_unifying_bootloader_nordic_erase (FuUnifyingBootloader *self, guint16 addr, G
} }
static gboolean static gboolean
fu_unifying_bootloader_nordic_write_firmware (FuDevice *device, fu_logitech_hidpp_bootloader_nordic_write_firmware (FuDevice *device,
FuFirmware *firmware, FuFirmware *firmware,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device);
const FuUnifyingBootloaderRequest *payload; const FuLogitechHidPpBootloaderRequest *payload;
guint16 addr; guint16 addr;
g_autoptr(GBytes) fw = NULL; g_autoptr(GBytes) fw = NULL;
g_autoptr(GPtrArray) reqs = 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 */ /* erase firmware pages up to the bootloader */
fu_device_set_status (device, FWUPD_STATUS_DEVICE_ERASE); fu_device_set_status (device, FWUPD_STATUS_DEVICE_ERASE);
for (addr = fu_unifying_bootloader_get_addr_lo (self); for (addr = fu_logitech_hidpp_bootloader_get_addr_lo (self);
addr < fu_unifying_bootloader_get_addr_hi (self); addr < fu_logitech_hidpp_bootloader_get_addr_hi (self);
addr += fu_unifying_bootloader_get_blocksize (self)) { addr += fu_logitech_hidpp_bootloader_get_blocksize (self)) {
if (!fu_unifying_bootloader_nordic_erase (self, addr, error)) if (!fu_logitech_hidpp_bootloader_nordic_erase (self, addr, error))
return FALSE; return FALSE;
} }
/* transfer payload */ /* transfer payload */
reqs = fu_unifying_bootloader_parse_requests (self, fw, error); reqs = fu_logitech_hidpp_bootloader_parse_requests (self, fw, error);
if (reqs == NULL) if (reqs == NULL)
return FALSE; return FALSE;
fu_device_set_status (device, FWUPD_STATUS_DEVICE_WRITE); 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); payload = g_ptr_array_index (reqs, i);
if (payload->cmd == FU_UNIFYING_BOOTLOADER_CMD_WRITE_SIGNATURE) { if (payload->cmd == FU_UNIFYING_BOOTLOADER_CMD_WRITE_SIGNATURE) {
res = fu_unifying_bootloader_nordic_write_signature (self, res = fu_logitech_hidpp_bootloader_nordic_write_signature (self,
payload->addr, payload->addr,
payload->len, payload->len,
payload->data, payload->data,
error); error);
} else { } else {
res = fu_unifying_bootloader_nordic_write (self, res = fu_logitech_hidpp_bootloader_nordic_write (self,
payload->addr, payload->addr,
payload->len, payload->len,
payload->data, payload->data,
error); error);
} }
if (!res) if (!res)
@ -250,18 +250,18 @@ fu_unifying_bootloader_nordic_write_firmware (FuDevice *device,
/* send the first managed packet last, excluding the reset vector */ /* send the first managed packet last, excluding the reset vector */
payload = g_ptr_array_index (reqs, 0); payload = g_ptr_array_index (reqs, 0);
if (!fu_unifying_bootloader_nordic_write (self, if (!fu_logitech_hidpp_bootloader_nordic_write (self,
payload->addr + 1, payload->addr + 1,
payload->len - 1, payload->len - 1,
payload->data + 1, payload->data + 1,
error)) error))
return FALSE; return FALSE;
if (!fu_unifying_bootloader_nordic_write (self, if (!fu_logitech_hidpp_bootloader_nordic_write (self,
0x0000, 0x0000,
0x01, 0x01,
payload->data, payload->data,
error)) error))
return FALSE; return FALSE;
/* mark as complete */ /* mark as complete */
@ -272,15 +272,15 @@ fu_unifying_bootloader_nordic_write_firmware (FuDevice *device,
} }
static void 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); FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass);
FuUnifyingBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass); FuLogitechHidPpBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass);
klass_device->write_firmware = fu_unifying_bootloader_nordic_write_firmware; klass_device->write_firmware = fu_logitech_hidpp_bootloader_nordic_write_firmware;
klass_device_bootloader->setup = fu_unifying_bootloader_nordic_setup; klass_device_bootloader->setup = fu_logitech_hidpp_bootloader_nordic_setup;
} }
static void static void
fu_unifying_bootloader_nordic_init (FuUnifyingBootloaderNordic *self) fu_logitech_hidpp_bootloader_nordic_init (FuLogitechHidPpBootloaderNordic *self)
{ {
} }

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -8,24 +8,24 @@
#include <string.h> #include <string.h>
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-bootloader-texas.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 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->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM;
req->len = 0x01; /* magic number */ req->len = 0x01; /* magic number */
req->data[0] = 0x00; /* 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: "); g_prefix_error (error, "failed to erase all pages: ");
return FALSE; return FALSE;
} }
@ -33,13 +33,13 @@ fu_unifying_bootloader_texas_erase_all (FuUnifyingBootloader *self, GError **err
} }
static gboolean 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->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM;
req->len = 0x01; /* magic number */ req->len = 0x01; /* magic number */
req->data[0] = 0x03; /* 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: "); g_prefix_error (error, "failed to compute and test CRC: ");
return FALSE; return FALSE;
} }
@ -54,14 +54,14 @@ fu_unifying_bootloader_texas_compute_and_test_crc (FuUnifyingBootloader *self, G
} }
static gboolean 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->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM;
req->addr = addr; req->addr = addr;
req->len = 0x01; /* magic number */ req->len = 0x01; /* magic number */
req->data[0] = 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); g_prefix_error (error, "failed to flash ram buffer @%04x: ", addr);
return FALSE; return FALSE;
} }
@ -93,14 +93,14 @@ fu_unifying_bootloader_texas_flash_ram_buffer (FuUnifyingBootloader *self, guint
} }
static gboolean 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->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM;
req->addr = 0x0000; req->addr = 0x0000;
req->len = 0x01; /* magic number */ req->len = 0x01; /* magic number */
req->data[0] = 0x02; /* 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); g_prefix_error (error, "failed to clear ram buffer @%04x: ", req->addr);
return FALSE; return FALSE;
} }
@ -108,16 +108,16 @@ fu_unifying_bootloader_texas_clear_ram_buffer (FuUnifyingBootloader *self, GErro
} }
static gboolean static gboolean
fu_unifying_bootloader_texas_write_firmware (FuDevice *device, fu_logitech_hidpp_bootloader_texas_write_firmware (FuDevice *device,
FuFirmware *firmware, FuFirmware *firmware,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device);
const FuUnifyingBootloaderRequest *payload; const FuLogitechHidPpBootloaderRequest *payload;
g_autoptr(GBytes) fw = NULL; g_autoptr(GBytes) fw = NULL;
g_autoptr(GPtrArray) reqs = 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 */ /* get default image */
fw = fu_firmware_get_image_default_bytes (firmware, error); fw = fu_firmware_get_image_default_bytes (firmware, error);
@ -125,17 +125,17 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device,
return FALSE; return FALSE;
/* transfer payload */ /* transfer payload */
reqs = fu_unifying_bootloader_parse_requests (self, fw, error); reqs = fu_logitech_hidpp_bootloader_parse_requests (self, fw, error);
if (reqs == NULL) if (reqs == NULL)
return FALSE; return FALSE;
/* erase all flash pages */ /* erase all flash pages */
fu_device_set_status (device, FWUPD_STATUS_DEVICE_ERASE); 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; return FALSE;
/* set existing RAM buffer to 0xff's */ /* 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; return FALSE;
/* write to RAM buffer */ /* write to RAM buffer */
@ -164,7 +164,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device,
req->len = payload->len; req->len = payload->len;
memcpy (req->data, payload->data, 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, g_prefix_error (error,
"failed to write ram buffer @0x%02x: ", "failed to write ram buffer @0x%02x: ",
req->addr); req->addr);
@ -193,7 +193,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device,
guint16 addr_start = payload->addr - (7 * 0x10); guint16 addr_start = payload->addr - (7 * 0x10);
g_debug ("addr flush @ 0x%04x for 0x%04x", g_debug ("addr flush @ 0x%04x for 0x%04x",
payload->addr, addr_start); 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, addr_start,
error)) { error)) {
g_prefix_error (error, g_prefix_error (error,
@ -208,7 +208,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device,
} }
/* check CRC */ /* 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; return FALSE;
/* mark as complete */ /* mark as complete */
@ -219,7 +219,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device,
} }
static gboolean 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", fu_device_set_version (FU_DEVICE (self), "RQR24.00_B0000",
FWUPD_VERSION_FORMAT_PLAIN); FWUPD_VERSION_FORMAT_PLAIN);
@ -227,15 +227,15 @@ fu_unifying_bootloader_texas_setup (FuUnifyingBootloader *self, GError **error)
} }
static void 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); FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass);
FuUnifyingBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass); FuLogitechHidPpBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass);
klass_device->write_firmware = fu_unifying_bootloader_texas_write_firmware; klass_device->write_firmware = fu_logitech_hidpp_bootloader_texas_write_firmware;
klass_device_bootloader->setup = fu_unifying_bootloader_texas_setup; klass_device_bootloader->setup = fu_logitech_hidpp_bootloader_texas_setup;
} }
static void static void
fu_unifying_bootloader_texas_init (FuUnifyingBootloaderTexas *self) fu_logitech_hidpp_bootloader_texas_init (FuLogitechHidPpBootloaderTexas *self)
{ {
} }

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -9,43 +9,43 @@
#include <string.h> #include <string.h>
#include "fu-firmware-common.h" #include "fu-firmware-common.h"
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-bootloader.h" #include "fu-logitech-hidpp-bootloader.h"
#include "fu-unifying-hidpp.h" #include "fu-logitech-hidpp-hidpp.h"
typedef struct typedef struct
{ {
guint16 flash_addr_lo; guint16 flash_addr_lo;
guint16 flash_addr_hi; guint16 flash_addr_hi;
guint16 flash_blocksize; guint16 flash_blocksize;
} FuUnifyingBootloaderPrivate; } FuLogitechHidPpBootloaderPrivate;
#define FU_UNIFYING_DEVICE_EP1 0x81 #define FU_UNIFYING_DEVICE_EP1 0x81
#define FU_UNIFYING_DEVICE_EP3 0x83 #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 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); FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device);
FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self);
fu_common_string_append_kx (str, idt, "FlashAddrHigh", priv->flash_addr_hi); 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, "FlashAddrLow", priv->flash_addr_lo);
fu_common_string_append_kx (str, idt, "FlashBlockSize", priv->flash_blocksize); fu_common_string_append_kx (str, idt, "FlashBlockSize", priv->flash_blocksize);
} }
FuUnifyingBootloaderRequest * FuLogitechHidPpBootloaderRequest *
fu_unifying_bootloader_request_new (void) fu_logitech_hidpp_bootloader_request_new (void)
{ {
FuUnifyingBootloaderRequest *req = g_new0 (FuUnifyingBootloaderRequest, 1); FuLogitechHidPpBootloaderRequest *req = g_new0 (FuLogitechHidPpBootloaderRequest, 1);
return req; return req;
} }
GPtrArray * 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; const gchar *tmp;
g_auto(GStrv) lines = NULL; 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); tmp = g_bytes_get_data (fw, NULL);
lines = g_strsplit_set (tmp, "\n\r", -1); lines = g_strsplit_set (tmp, "\n\r", -1);
for (guint i = 0; lines[i] != NULL; i++) { for (guint i = 0; lines[i] != NULL; i++) {
g_autoptr(FuUnifyingBootloaderRequest) payload = NULL; g_autoptr(FuLogitechHidPpBootloaderRequest) payload = NULL;
guint8 rec_type = 0x00; guint8 rec_type = 0x00;
guint16 offset = 0x0000; guint16 offset = 0x0000;
gboolean exit = FALSE; gboolean exit = FALSE;
@ -66,8 +66,8 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G
if (strlen (tmp) < 5) if (strlen (tmp) < 5)
continue; continue;
payload = fu_unifying_bootloader_request_new (); payload = fu_logitech_hidpp_bootloader_request_new ();
payload->len = fu_unifying_buffer_read_uint8 (tmp + 0x01); payload->len = fu_logitech_hidpp_buffer_read_uint8 (tmp + 0x01);
if (payload->len > 28) { if (payload->len > 28) {
g_set_error (error, g_set_error (error,
G_IO_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->addr = fu_firmware_strparse_uint16 (tmp + 0x03);
payload->cmd = FU_UNIFYING_BOOTLOADER_CMD_WRITE_RAM_BUFFER; 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) { switch (rec_type) {
case 0x00: /* data */ case 0x00: /* data */
@ -134,7 +134,7 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G
payload->len); payload->len);
return NULL; 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 */ /* no need to bound check signature addresses */
@ -144,13 +144,13 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G
} }
/* skip the bootloader */ /* 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); g_debug ("skipping write @ %04x", payload->addr);
continue; continue;
} }
/* skip the header */ /* 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); g_debug ("skipping write @ %04x", payload->addr);
continue; continue;
} }
@ -176,36 +176,36 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G
} }
guint16 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); g_return_val_if_fail (FU_IS_UNIFYING_BOOTLOADER (self), 0x0000);
return priv->flash_addr_lo; return priv->flash_addr_lo;
} }
guint16 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); g_return_val_if_fail (FU_IS_UNIFYING_BOOTLOADER (self), 0x0000);
return priv->flash_addr_hi; return priv->flash_addr_hi;
} }
guint16 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); g_return_val_if_fail (FU_IS_UNIFYING_BOOTLOADER (self), 0x0000);
return priv->flash_blocksize; return priv->flash_blocksize;
} }
static gboolean 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); FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device);
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_REBOOT; 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: "); g_prefix_error (error, "failed to attach back to runtime: ");
return FALSE; return FALSE;
} }
@ -214,26 +214,26 @@ fu_unifying_bootloader_attach (FuDevice *device, GError **error)
} }
static gboolean 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; guint16 build;
g_autofree gchar *version = NULL; 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 */ /* call into hardware */
req->cmd = FU_UNIFYING_BOOTLOADER_CMD_GET_BL_VERSION; 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: "); g_prefix_error (error, "failed to get firmware version: ");
return FALSE; return FALSE;
} }
/* BOTxx.yy_Bzzzz /* BOTxx.yy_Bzzzz
* 012345678901234 */ * 012345678901234 */
build = (guint16) fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 10) << 8; build = (guint16) fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 10) << 8;
build += fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 12); build += fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 12);
version = fu_unifying_format_version ("BOT", version = fu_logitech_hidpp_format_version ("BOT",
fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 3), fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 3),
fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 6), fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 6),
build); build);
if (version == NULL) { if (version == NULL) {
g_prefix_error (error, "failed to format firmware version: "); 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 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); GUsbDevice *usb_device = fu_usb_device_get_dev (device);
const guint idx = 0x00; const guint idx = 0x00;
@ -262,16 +262,16 @@ fu_unifying_bootloader_open (FuUsbDevice *device, GError **error)
} }
static gboolean 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); FuLogitechHidPpBootloaderClass *klass = FU_UNIFYING_BOOTLOADER_GET_CLASS (device);
FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device);
FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self);
g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new ();
/* get memory map */ /* get memory map */
req->cmd = FU_UNIFYING_BOOTLOADER_CMD_GET_MEMINFO; 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: "); g_prefix_error (error, "failed to get meminfo: ");
return FALSE; 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); priv->flash_blocksize = fu_common_read_uint16 (req->data + 4, G_BIG_ENDIAN);
/* get bootloader version */ /* get bootloader version */
if (!fu_unifying_bootloader_set_bl_version (self, error)) if (!fu_logitech_hidpp_bootloader_set_bl_version (self, error))
return FALSE; return FALSE;
/* subclassed further */ /* subclassed further */
@ -302,7 +302,7 @@ fu_unifying_bootloader_setup (FuDevice *device, GError **error)
} }
static gboolean 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); GUsbDevice *usb_device = fu_usb_device_get_dev (device);
if (usb_device != NULL) { if (usb_device != NULL) {
@ -316,9 +316,9 @@ fu_unifying_bootloader_close (FuUsbDevice *device, GError **error)
} }
gboolean gboolean
fu_unifying_bootloader_request (FuUnifyingBootloader *self, fu_logitech_hidpp_bootloader_request (FuLogitechHidPpBootloader *self,
FuUnifyingBootloaderRequest *req, FuLogitechHidPpBootloaderRequest *req,
GError **error) GError **error)
{ {
GUsbDevice *usb_device = fu_usb_device_get_dev (FU_USB_DEVICE (self)); GUsbDevice *usb_device = fu_usb_device_get_dev (FU_USB_DEVICE (self));
gsize actual_length = 0; gsize actual_length = 0;
@ -440,7 +440,7 @@ fu_unifying_bootloader_request (FuUnifyingBootloader *self,
} }
static void 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_UPDATABLE);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER);
@ -452,13 +452,13 @@ fu_unifying_bootloader_init (FuUnifyingBootloader *self)
} }
static void static void
fu_unifying_bootloader_class_init (FuUnifyingBootloaderClass *klass) fu_logitech_hidpp_bootloader_class_init (FuLogitechHidPpBootloaderClass *klass)
{ {
FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass);
FuUsbDeviceClass *klass_usb_device = FU_USB_DEVICE_CLASS (klass); FuUsbDeviceClass *klass_usb_device = FU_USB_DEVICE_CLASS (klass);
klass_device->to_string = fu_unifying_bootloader_to_string; klass_device->to_string = fu_logitech_hidpp_bootloader_to_string;
klass_device->attach = fu_unifying_bootloader_attach; klass_device->attach = fu_logitech_hidpp_bootloader_attach;
klass_device->setup = fu_unifying_bootloader_setup; klass_device->setup = fu_logitech_hidpp_bootloader_setup;
klass_usb_device->open = fu_unifying_bootloader_open; klass_usb_device->open = fu_logitech_hidpp_bootloader_open;
klass_usb_device->close = fu_unifying_bootloader_close; klass_usb_device->close = fu_logitech_hidpp_bootloader_close;
} }

View File

@ -8,13 +8,13 @@
#include "fu-usb-device.h" #include "fu-usb-device.h"
#define FU_TYPE_UNIFYING_BOOTLOADER (fu_unifying_bootloader_get_type ()) #define FU_TYPE_UNIFYING_BOOTLOADER (fu_logitech_hidpp_bootloader_get_type ())
G_DECLARE_DERIVABLE_TYPE (FuUnifyingBootloader, fu_unifying_bootloader, FU, UNIFYING_BOOTLOADER, FuUsbDevice) G_DECLARE_DERIVABLE_TYPE (FuLogitechHidPpBootloader, fu_logitech_hidpp_bootloader, FU, UNIFYING_BOOTLOADER, FuUsbDevice)
struct _FuUnifyingBootloaderClass struct _FuLogitechHidPpBootloaderClass
{ {
FuUsbDeviceClass parent_class; FuUsbDeviceClass parent_class;
gboolean (*setup) (FuUnifyingBootloader *self, gboolean (*setup) (FuLogitechHidPpBootloader *self,
GError **error); GError **error);
}; };
@ -47,7 +47,7 @@ typedef enum {
FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM_INVALID_ORDER = 0xd4, FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM_INVALID_ORDER = 0xd4,
FU_UNIFYING_BOOTLOADER_CMD_WRITE_SIGNATURE = 0xe0, FU_UNIFYING_BOOTLOADER_CMD_WRITE_SIGNATURE = 0xe0,
FU_UNIFYING_BOOTLOADER_CMD_LAST FU_UNIFYING_BOOTLOADER_CMD_LAST
} FuUnifyingBootloaderCmd; } FuLogitechHidPpBootloaderCmd;
/* packet to and from device */ /* packet to and from device */
typedef struct __attribute__((packed)) { typedef struct __attribute__((packed)) {
@ -55,22 +55,22 @@ typedef struct __attribute__((packed)) {
guint16 addr; guint16 addr;
guint8 len; guint8 len;
guint8 data[28]; 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 push
#pragma clang diagnostic ignored "-Wunused-function" #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 #pragma clang diagnostic pop
GPtrArray *fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GPtrArray *fu_logitech_hidpp_bootloader_parse_requests (FuLogitechHidPpBootloader *self,
GBytes *fw, GBytes *fw,
GError **error); GError **error);
gboolean fu_unifying_bootloader_request (FuUnifyingBootloader *self, gboolean fu_logitech_hidpp_bootloader_request (FuLogitechHidPpBootloader *self,
FuUnifyingBootloaderRequest *req, FuLogitechHidPpBootloaderRequest *req,
GError **error); GError **error);
guint16 fu_unifying_bootloader_get_addr_lo (FuUnifyingBootloader *self); guint16 fu_logitech_hidpp_bootloader_get_addr_lo (FuLogitechHidPpBootloader *self);
guint16 fu_unifying_bootloader_get_addr_hi (FuUnifyingBootloader *self); guint16 fu_logitech_hidpp_bootloader_get_addr_hi (FuLogitechHidPpBootloader *self);
guint16 fu_unifying_bootloader_get_blocksize (FuUnifyingBootloader *self); guint16 fu_logitech_hidpp_bootloader_get_blocksize (FuLogitechHidPpBootloader *self);

View File

@ -11,10 +11,10 @@
#include <errno.h> #include <errno.h>
#include <gio/gio.h> #include <gio/gio.h>
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
guint8 guint8
fu_unifying_buffer_read_uint8 (const gchar *str) fu_logitech_hidpp_buffer_read_uint8 (const gchar *str)
{ {
guint64 tmp; guint64 tmp;
gchar buf[3] = { 0x0, 0x0, 0x0 }; gchar buf[3] = { 0x0, 0x0, 0x0 };
@ -24,7 +24,7 @@ fu_unifying_buffer_read_uint8 (const gchar *str)
} }
guint16 guint16
fu_unifying_buffer_read_uint16 (const gchar *str) fu_logitech_hidpp_buffer_read_uint16 (const gchar *str)
{ {
guint64 tmp; guint64 tmp;
gchar buf[5] = { 0x0, 0x0, 0x0, 0x0, 0x0 }; gchar buf[5] = { 0x0, 0x0, 0x0, 0x0, 0x0 };
@ -34,7 +34,7 @@ fu_unifying_buffer_read_uint16 (const gchar *str)
} }
gchar * 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); GString *str = g_string_new (NULL);
for (guint i = 0; i < 3; i++) { for (guint i = 0; i < 3; i++) {

View File

@ -19,10 +19,10 @@
/* Signed firmware are very long to verify on the device */ /* Signed firmware are very long to verify on the device */
#define FU_UNIFYING_DEVICE_TIMEOUT_MS 30000 #define FU_UNIFYING_DEVICE_TIMEOUT_MS 30000
guint8 fu_unifying_buffer_read_uint8 (const gchar *str); guint8 fu_logitech_hidpp_buffer_read_uint8 (const gchar *str);
guint16 fu_unifying_buffer_read_uint16 (const gchar *str); guint16 fu_logitech_hidpp_buffer_read_uint16 (const gchar *str);
gchar *fu_unifying_format_version (const gchar *name, gchar *fu_logitech_hidpp_format_version (const gchar *name,
guint8 major, guint8 major,
guint8 minor, guint8 minor,
guint16 build); guint16 build);

View File

@ -8,17 +8,17 @@
#include <string.h> #include <string.h>
#include "fu-unifying-hidpp.h" #include "fu-logitech-hidpp-hidpp.h"
#include "fu-unifying-hidpp-msg.h" #include "fu-logitech-hidpp-hidpp-msg.h"
FuUnifyingHidppMsg * FuLogitechHidPpHidppMsg *
fu_unifying_hidpp_msg_new (void) fu_logitech_hidpp_msg_new (void)
{ {
return g_new0 (FuUnifyingHidppMsg, 1); return g_new0 (FuLogitechHidPpHidppMsg, 1);
} }
const gchar * 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); g_return_val_if_fail (msg != NULL, NULL);
if (msg->device_id == HIDPP_DEVICE_ID_WIRED) if (msg->device_id == HIDPP_DEVICE_ID_WIRED)
@ -31,7 +31,7 @@ fu_unifying_hidpp_msg_dev_id_to_string (FuUnifyingHidppMsg *msg)
} }
const gchar * 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); g_return_val_if_fail (msg != NULL, NULL);
if (msg->report_id == HIDPP_REPORT_ID_SHORT) if (msg->report_id == HIDPP_REPORT_ID_SHORT)
@ -44,7 +44,7 @@ fu_unifying_hidpp_msg_rpt_id_to_string (FuUnifyingHidppMsg *msg)
} }
gsize 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) if (msg->report_id == HIDPP_REPORT_ID_SHORT)
return 0x07; return 0x07;
@ -58,7 +58,7 @@ fu_unifying_hidpp_msg_get_payload_length (FuUnifyingHidppMsg *msg)
} }
const gchar * 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); g_return_val_if_fail (msg != NULL, NULL);
switch (msg->sub_id) { switch (msg->sub_id) {
@ -113,7 +113,7 @@ fu_unifying_hidpp_msg_fcn_id_to_string (FuUnifyingHidppMsg *msg)
} }
const gchar * 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); g_return_val_if_fail (msg != NULL, NULL);
if (msg->sub_id == HIDPP_SUBID_VENDOR_SPECIFIC_KEYS) if (msg->sub_id == HIDPP_SUBID_VENDOR_SPECIFIC_KEYS)
@ -196,7 +196,7 @@ fu_unifying_hidpp_msg_sub_id_to_string (FuUnifyingHidppMsg *msg)
} }
gboolean 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 (msg1 != NULL, FALSE);
g_return_val_if_fail (msg2 != 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 */ /* HID++ error */
gboolean 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); g_return_val_if_fail (msg != NULL, FALSE);
if (msg->sub_id == HIDPP_SUBID_ERROR_MSG) { if (msg->sub_id == HIDPP_SUBID_ERROR_MSG) {
@ -362,7 +362,7 @@ fu_unifying_hidpp_msg_is_error (FuUnifyingHidppMsg *msg, GError **error)
} }
void 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_dst != NULL);
g_return_if_fail (msg_src != 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 */ /* filter HID++1.0 messages */
gboolean 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); g_return_val_if_fail (msg != NULL, FALSE);
if (msg->sub_id == 0x40 || if (msg->sub_id == 0x40 ||
@ -389,7 +389,7 @@ fu_unifying_hidpp_msg_is_hidpp10_compat (FuUnifyingHidppMsg *msg)
} }
gboolean 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); g_return_val_if_fail (msg != NULL, FALSE);
if ((msg->function_id & 0x0f) != FU_UNIFYING_HIDPP_MSG_SW_ID) if ((msg->function_id & 0x0f) != FU_UNIFYING_HIDPP_MSG_SW_ID)

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2017-2018 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib.h>
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);

View File

@ -7,11 +7,11 @@
#include "config.h" #include "config.h"
#include "fu-common.h" #include "fu-common.h"
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-hidpp.h" #include "fu-logitech-hidpp-hidpp.h"
static gchar * static gchar *
fu_unifying_hidpp_msg_to_string (FuUnifyingHidppMsg *msg) fu_logitech_hidpp_msg_to_string (FuLogitechHidPpHidppMsg *msg)
{ {
GString *str = g_string_new (NULL); GString *str = g_string_new (NULL);
const gchar *tmp; const gchar *tmp;
@ -39,17 +39,17 @@ fu_unifying_hidpp_msg_to_string (FuUnifyingHidppMsg *msg)
flags_str->str); flags_str->str);
g_string_append_printf (str, "report-id: %02x [%s]\n", g_string_append_printf (str, "report-id: %02x [%s]\n",
msg->report_id, msg->report_id,
fu_unifying_hidpp_msg_rpt_id_to_string (msg)); fu_logitech_hidpp_msg_rpt_id_to_string (msg));
tmp = fu_unifying_hidpp_msg_dev_id_to_string (msg); tmp = fu_logitech_hidpp_msg_dev_id_to_string (msg);
g_string_append_printf (str, "device-id: %02x [%s]\n", g_string_append_printf (str, "device-id: %02x [%s]\n",
msg->device_id, tmp ); msg->device_id, tmp );
g_string_append_printf (str, "sub-id: %02x [%s]\n", g_string_append_printf (str, "sub-id: %02x [%s]\n",
msg->sub_id, 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", g_string_append_printf (str, "function-id: %02x [%s]\n",
msg->function_id, msg->function_id,
fu_unifying_hidpp_msg_fcn_id_to_string (msg)); fu_logitech_hidpp_msg_fcn_id_to_string (msg));
if (!fu_unifying_hidpp_msg_is_error (msg, &error)) { if (!fu_logitech_hidpp_msg_is_error (msg, &error)) {
g_string_append_printf (str, "error: %s\n", g_string_append_printf (str, "error: %s\n",
error->message); error->message);
} }
@ -57,12 +57,12 @@ fu_unifying_hidpp_msg_to_string (FuUnifyingHidppMsg *msg)
} }
gboolean gboolean
fu_unifying_hidpp_send (FuIOChannel *io_channel, fu_logitech_hidpp_send (FuIOChannel *io_channel,
FuUnifyingHidppMsg *msg, FuLogitechHidPpHidppMsg *msg,
guint timeout, guint timeout,
GError **error) 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 */ /* only for HID++2.0 */
if (msg->hidpp_version >= 2.f) if (msg->hidpp_version >= 2.f)
@ -70,7 +70,7 @@ fu_unifying_hidpp_send (FuIOChannel *io_channel,
/* detailed debugging */ /* detailed debugging */
if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL) { 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); fu_common_dump_raw (G_LOG_DOMAIN, "host->device", (guint8 *) msg, len);
g_print ("%s", str); g_print ("%s", str);
} }
@ -88,8 +88,8 @@ fu_unifying_hidpp_send (FuIOChannel *io_channel,
} }
gboolean gboolean
fu_unifying_hidpp_receive (FuIOChannel *io_channel, fu_logitech_hidpp_receive (FuIOChannel *io_channel,
FuUnifyingHidppMsg *msg, FuLogitechHidPpHidppMsg *msg,
guint timeout, guint timeout,
GError **error) GError **error)
{ {
@ -97,7 +97,7 @@ fu_unifying_hidpp_receive (FuIOChannel *io_channel,
if (!fu_io_channel_read_raw (io_channel, if (!fu_io_channel_read_raw (io_channel,
(guint8 *) msg, (guint8 *) msg,
sizeof(FuUnifyingHidppMsg), sizeof(FuLogitechHidPpHidppMsg),
&read_size, &read_size,
timeout, timeout,
FU_IO_CHANNEL_FLAG_SINGLE_SHOT, 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 */ /* check long enough, but allow returning oversize packets */
if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL) if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL)
fu_common_dump_raw (G_LOG_DOMAIN, "device->host", (guint8 *) msg, read_size); 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_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_FAILED, G_IO_ERROR_FAILED,
"message length too small, " "message length too small, "
"got %" G_GSIZE_FORMAT " expected %" G_GSIZE_FORMAT, "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; return FALSE;
} }
/* detailed debugging */ /* detailed debugging */
if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL) { 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); g_print ("%s", str);
} }
@ -130,30 +130,30 @@ fu_unifying_hidpp_receive (FuIOChannel *io_channel,
} }
gboolean 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 timeout = FU_UNIFYING_DEVICE_TIMEOUT_MS;
guint ignore_cnt = 0; 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 */ /* increase timeout for some operations */
if (msg->flags & FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT) if (msg->flags & FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT)
timeout *= 10; timeout *= 10;
/* send request */ /* send request */
if (!fu_unifying_hidpp_send (io_channel, msg, timeout, error)) if (!fu_logitech_hidpp_send (io_channel, msg, timeout, error))
return FALSE; return FALSE;
/* keep trying to receive until we get a valid reply */ /* keep trying to receive until we get a valid reply */
while (1) { while (1) {
msg_tmp->hidpp_version = msg->hidpp_version; 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: "); g_prefix_error (error, "failed to receive: ");
return FALSE; return FALSE;
} }
/* we don't know how to handle this report packet */ /* 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", g_debug ("HID++1.0 report 0x%02x has unknown length, ignoring",
msg_tmp->report_id); msg_tmp->report_id);
continue; continue;
@ -161,11 +161,11 @@ fu_unifying_hidpp_transfer (FuIOChannel *io_channel, FuUnifyingHidppMsg *msg, GE
/* maybe something is also writing to the device? -- /* maybe something is also writing to the device? --
* we can't use the SwID as this is a HID++2.0 feature */ * 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; return FALSE;
/* is valid reply */ /* is valid reply */
if (fu_unifying_hidpp_msg_is_reply (msg, msg_tmp)) if (fu_logitech_hidpp_msg_is_reply (msg, msg_tmp))
break; break;
/* to ensure compatibility when an HID++ 2.0 device is /* 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 * corresponding to an HID++ 1.0 sub-identifier which could be
* sent by the receiver, must be assigned to a dummy feature */ * sent by the receiver, must be assigned to a dummy feature */
if (msg->hidpp_version >= 2.f) { 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"); g_debug ("ignoring HID++1.0 reply");
continue; continue;
} }
/* not us */ /* not us */
if ((msg->flags & FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID) == 0) { 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", g_debug ("ignoring reply with SwId 0x%02i, expected 0x%02i",
msg_tmp->function_id & 0x0f, msg_tmp->function_id & 0x0f,
FU_UNIFYING_HIDPP_MSG_SW_ID); FU_UNIFYING_HIDPP_MSG_SW_ID);
@ -202,6 +202,6 @@ fu_unifying_hidpp_transfer (FuIOChannel *io_channel, FuUnifyingHidppMsg *msg, GE
}; };
/* copy over data */ /* copy over data */
fu_unifying_hidpp_msg_copy (msg, msg_tmp); fu_logitech_hidpp_msg_copy (msg, msg_tmp);
return TRUE; return TRUE;
} }

View File

@ -133,16 +133,16 @@
#define HIDPP_FEATURE_ONBOARD_PROFILES 0x8100 #define HIDPP_FEATURE_ONBOARD_PROFILES 0x8100
#define HIDPP_FEATURE_MOUSE_BUTTON_SPY 0x8110 #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, gboolean fu_logitech_hidpp_send (FuIOChannel *self,
FuUnifyingHidppMsg *msg, FuLogitechHidPpHidppMsg *msg,
guint timeout, guint timeout,
GError **error); GError **error);
gboolean fu_unifying_hidpp_receive (FuIOChannel *self, gboolean fu_logitech_hidpp_receive (FuIOChannel *self,
FuUnifyingHidppMsg *msg, FuLogitechHidPpHidppMsg *msg,
guint timeout, guint timeout,
GError **error); GError **error);
gboolean fu_unifying_hidpp_transfer (FuIOChannel *self, gboolean fu_logitech_hidpp_transfer (FuIOChannel *self,
FuUnifyingHidppMsg *msg, FuLogitechHidPpHidppMsg *msg,
GError **error); GError **error);

View File

@ -8,11 +8,11 @@
#include <string.h> #include <string.h>
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-peripheral.h" #include "fu-logitech-hidpp-peripheral.h"
#include "fu-unifying-hidpp.h" #include "fu-logitech-hidpp-hidpp.h"
struct _FuUnifyingPeripheral struct _FuLogitechHidPpPeripheral
{ {
FuUdevDevice parent_instance; FuUdevDevice parent_instance;
guint8 battery_level; guint8 battery_level;
@ -22,15 +22,15 @@ struct _FuUnifyingPeripheral
gboolean is_updatable; gboolean is_updatable;
gboolean is_active; gboolean is_active;
FuIOChannel *io_channel; FuIOChannel *io_channel;
GPtrArray *feature_index; /* of FuUnifyingHidppMap */ GPtrArray *feature_index; /* of FuLogitechHidPpHidppMap */
}; };
typedef struct { typedef struct {
guint8 idx; guint8 idx;
guint16 feature; 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 { typedef enum {
FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD, FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD,
@ -42,10 +42,10 @@ typedef enum {
FU_UNIFYING_PERIPHERAL_KIND_PRESENTER, FU_UNIFYING_PERIPHERAL_KIND_PRESENTER,
FU_UNIFYING_PERIPHERAL_KIND_RECEIVER, FU_UNIFYING_PERIPHERAL_KIND_RECEIVER,
FU_UNIFYING_PERIPHERAL_KIND_LAST FU_UNIFYING_PERIPHERAL_KIND_LAST
} FuUnifyingPeripheralKind; } FuLogitechHidPpPeripheralKind;
static const gchar * 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) if (kind == FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD)
return "input-keyboard"; return "input-keyboard";
@ -67,7 +67,7 @@ fu_unifying_peripheral_get_icon (FuUnifyingPeripheralKind kind)
} }
static const gchar * 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) if (kind == FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD)
return "Unifying Keyboard"; return "Unifying Keyboard";
@ -89,7 +89,7 @@ fu_unifying_peripheral_get_summary (FuUnifyingPeripheralKind kind)
} }
static const gchar * static const gchar *
fu_unifying_hidpp_feature_to_string (guint16 feature) fu_logitech_hidpp_feature_to_string (guint16 feature)
{ {
if (feature == HIDPP_FEATURE_ROOT) if (feature == HIDPP_FEATURE_ROOT)
return "Root"; return "Root";
@ -109,7 +109,7 @@ fu_unifying_hidpp_feature_to_string (guint16 feature)
} }
static void 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 */ /* device can only be upgraded if it is capable, and active */
if (self->is_updatable && self->is_active) { if (self->is_updatable && self->is_active) {
@ -120,11 +120,11 @@ fu_unifying_peripheral_refresh_updatable (FuUnifyingPeripheral *self)
} }
static gboolean static gboolean
fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error) fu_logitech_hidpp_peripheral_ping (FuLogitechHidPpPeripheral *self, GError **error)
{ {
gdouble version; gdouble version;
g_autoptr(GError) error_local = NULL; 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 */ /* handle failure */
msg->report_id = HIDPP_REPORT_ID_SHORT; 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[1] = 0x00;
msg->data[2] = 0xaa; /* user-selected value */ msg->data[2] = 0xaa; /* user-selected value */
msg->hidpp_version = self->hidpp_version; 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, if (g_error_matches (error_local,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED)) { G_IO_ERROR_NOT_SUPPORTED)) {
@ -146,7 +146,7 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error)
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_HOST_UNREACHABLE)) { G_IO_ERROR_HOST_UNREACHABLE)) {
self->is_active = FALSE; self->is_active = FALSE;
fu_unifying_peripheral_refresh_updatable (self); fu_logitech_hidpp_peripheral_refresh_updatable (self);
return TRUE; return TRUE;
} }
g_set_error (error, g_set_error (error,
@ -160,7 +160,7 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error)
/* device no longer asleep */ /* device no longer asleep */
self->is_active = TRUE; 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 the HID++ ID is unset, grab it from the reply */
if (self->hidpp_id == HIDPP_DEVICE_ID_UNSET) { if (self->hidpp_id == HIDPP_DEVICE_ID_UNSET) {
@ -177,9 +177,9 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error)
} }
static gboolean 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)) if (!fu_io_channel_shutdown (self->io_channel, error))
return FALSE; return FALSE;
g_clear_object (&self->io_channel); g_clear_object (&self->io_channel);
@ -187,12 +187,12 @@ fu_unifying_peripheral_close (FuDevice *device, GError **error)
} }
static gboolean 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 */ const guint timeout = 1; /* ms */
g_autoptr(GError) error_local = NULL; 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; g_autoptr(FuDeviceLocker) locker = NULL;
/* open */ /* open */
@ -203,7 +203,7 @@ fu_unifying_peripheral_poll (FuDevice *device, GError **error)
/* flush pending data */ /* flush pending data */
msg->device_id = self->hidpp_id; msg->device_id = self->hidpp_id;
msg->hidpp_version = self->hidpp_version; 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, if (!g_error_matches (error_local,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_TIMED_OUT)) { G_IO_ERROR_TIMED_OUT)) {
@ -215,7 +215,7 @@ fu_unifying_peripheral_poll (FuDevice *device, GError **error)
} }
/* just ping */ /* 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); g_warning ("failed to ping device: %s", error_local->message);
return TRUE; return TRUE;
} }
@ -232,9 +232,9 @@ fu_unifying_peripheral_poll (FuDevice *device, GError **error)
} }
static gboolean 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)); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (device));
const gchar *devpath = g_udev_device_get_device_file (udev_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 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 *title = g_strdup_printf ("Feature%02x", map->idx);
g_autofree gchar *tmp = g_strdup_printf ("%s [0x%04x]", 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); map->feature);
fu_common_string_append_kv (str, idt, title, tmp); fu_common_string_append_kv (str, idt, title, tmp);
} }
static void 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_ku (str, idt, "HidppVersion", self->hidpp_version);
fu_common_string_append_kx (str, idt, "HidppId", self->hidpp_id); 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_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, "IsUpdatable", self->is_updatable);
fu_common_string_append_kb (str, idt, "IsActive", self->is_active); fu_common_string_append_kb (str, idt, "IsActive", self->is_active);
for (guint i = 0; i < self->feature_index->len; i++) { 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);
fu_unifying_hidpp_map_to_string (map, idt, str); fu_logitech_hidpp_map_to_string (map, idt, str);
} }
} }
static guint8 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++) { 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) if (map->feature == feature)
return map->idx; return map->idx;
} }
@ -283,14 +283,14 @@ fu_unifying_peripheral_feature_get_idx (FuUnifyingPeripheral *self, guint16 feat
} }
static gboolean 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 idx;
guint8 entity_count; 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 */ /* 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) if (idx == 0x00)
return TRUE; return TRUE;
@ -300,7 +300,7 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError *
msg->sub_id = idx; msg->sub_id = idx;
msg->function_id = 0x00 << 4; /* getCount */ msg->function_id = 0x00 << 4; /* getCount */
msg->hidpp_version = self->hidpp_version; 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: "); g_prefix_error (error, "failed to get firmware count: ");
return FALSE; return FALSE;
} }
@ -318,7 +318,7 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError *
msg->sub_id = idx; msg->sub_id = idx;
msg->function_id = 0x01 << 4; /* getInfo */ msg->function_id = 0x01 << 4; /* getInfo */
msg->data[0] = i; 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: "); g_prefix_error (error, "failed to get firmware info: ");
return FALSE; return FALSE;
} }
@ -337,7 +337,7 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError *
msg->data[2], msg->data[2],
msg->data[3]); msg->data[3]);
build = ((guint16) msg->data[6]) << 8 | msg->data[7]; 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[4],
msg->data[5], msg->data[5],
build); build);
@ -358,20 +358,20 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError *
} }
static gboolean 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 */ /* try using HID++2.0 */
if (self->hidpp_version >= 2.f) { if (self->hidpp_version >= 2.f) {
guint8 idx; 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) { 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->report_id = HIDPP_REPORT_ID_SHORT;
msg->device_id = self->hidpp_id; msg->device_id = self->hidpp_id;
msg->sub_id = idx; msg->sub_id = idx;
msg->function_id = 0x00; /* GetBatteryLevelStatus */ msg->function_id = 0x00; /* GetBatteryLevelStatus */
msg->hidpp_version = self->hidpp_version; 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: "); g_prefix_error (error, "failed to get battery info: ");
return FALSE; return FALSE;
} }
@ -383,13 +383,13 @@ fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError *
/* try HID++1.0 battery mileage */ /* try HID++1.0 battery mileage */
if (self->hidpp_version == 1.f) { 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->report_id = HIDPP_REPORT_ID_SHORT;
msg->device_id = self->hidpp_id; msg->device_id = self->hidpp_id;
msg->sub_id = HIDPP_SUBID_GET_REGISTER; msg->sub_id = HIDPP_SUBID_GET_REGISTER;
msg->function_id = HIDPP_REGISTER_BATTERY_MILEAGE; msg->function_id = HIDPP_REGISTER_BATTERY_MILEAGE;
msg->hidpp_version = self->hidpp_version; 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) if (msg->data[0] != 0x00)
self->battery_level = msg->data[0]; self->battery_level = msg->data[0];
return TRUE; return TRUE;
@ -397,7 +397,7 @@ fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError *
/* try HID++1.0 battery status instead */ /* try HID++1.0 battery status instead */
msg->function_id = HIDPP_REGISTER_BATTERY_STATUS; 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]) { switch (msg->data[0]) {
case 1: /* 0 - 10 */ case 1: /* 0 - 10 */
self->battery_level = 5; self->battery_level = 5;
@ -425,11 +425,11 @@ fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError *
} }
static gboolean 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); FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device);
FuUnifyingHidppMap *map; FuLogitechHidPpHidppMap *map;
g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new ();
/* find the idx for the feature */ /* find the idx for the feature */
msg->report_id = HIDPP_REPORT_ID_SHORT; 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[1] = feature;
msg->data[2] = 0x00; msg->data[2] = 0x00;
msg->hidpp_version = self->hidpp_version; 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, g_prefix_error (error,
"failed to get idx for feature %s [0x%04x]: ", "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; return FALSE;
} }
@ -453,22 +453,22 @@ fu_unifying_hidpp_feature_search (FuDevice *device, guint16 feature, GError **er
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED, G_IO_ERROR_NOT_SUPPORTED,
"feature %s [0x%04x] not found", "feature %s [0x%04x] not found",
fu_unifying_hidpp_feature_to_string (feature), feature); fu_logitech_hidpp_feature_to_string (feature), feature);
return FALSE; return FALSE;
} }
/* add to map */ /* add to map */
map = g_new0 (FuUnifyingHidppMap, 1); map = g_new0 (FuLogitechHidPpHidppMap, 1);
map->idx = msg->data[0]; map->idx = msg->data[0];
map->feature = feature; map->feature = feature;
g_ptr_array_add (self->feature_index, map); g_ptr_array_add (self->feature_index, map);
g_debug ("added feature %s [0x%04x] as idx %02x", 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; return TRUE;
} }
static gboolean static gboolean
fu_unifying_peripheral_probe (FuUdevDevice *device, GError **error) fu_logitech_hidpp_peripheral_probe (FuUdevDevice *device, GError **error)
{ {
g_autofree gchar *devid = NULL; g_autofree gchar *devid = NULL;
@ -488,9 +488,9 @@ fu_unifying_peripheral_probe (FuUdevDevice *device, GError **error)
} }
static gboolean 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; guint8 idx;
const guint16 map_features[] = { const guint16 map_features[] = {
HIDPP_FEATURE_GET_DEVICE_NAME_TYPE, HIDPP_FEATURE_GET_DEVICE_NAME_TYPE,
@ -502,13 +502,13 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error)
HIDPP_FEATURE_ROOT }; HIDPP_FEATURE_ROOT };
/* ping device to get HID++ version */ /* ping device to get HID++ version */
if (!fu_unifying_peripheral_ping (self, error)) if (!fu_logitech_hidpp_peripheral_ping (self, error))
return FALSE; return FALSE;
/* add known root for HID++2.0 */ /* add known root for HID++2.0 */
g_ptr_array_set_size (self->feature_index, 0); g_ptr_array_set_size (self->feature_index, 0);
if (self->hidpp_version >= 2.f) { if (self->hidpp_version >= 2.f) {
FuUnifyingHidppMap *map = g_new0 (FuUnifyingHidppMap, 1); FuLogitechHidPpHidppMap *map = g_new0 (FuLogitechHidPpHidppMap, 1);
map->idx = 0x00; map->idx = 0x00;
map->feature = HIDPP_FEATURE_ROOT; map->feature = HIDPP_FEATURE_ROOT;
g_ptr_array_add (self->feature_index, map); 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 */ /* map some *optional* HID++2.0 features we might use */
for (guint i = 0; map_features[i] != HIDPP_FEATURE_ROOT; i++) { for (guint i = 0; map_features[i] != HIDPP_FEATURE_ROOT; i++) {
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
if (!fu_unifying_hidpp_feature_search (device, if (!fu_logitech_hidpp_feature_search (device,
map_features[i], map_features[i],
&error_local)) { &error_local)) {
g_debug ("%s", error_local->message); g_debug ("%s", error_local->message);
@ -534,51 +534,51 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error)
} }
/* get the firmware information */ /* 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; return FALSE;
/* get the battery level */ /* 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; return FALSE;
/* try using HID++2.0 */ /* 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) { if (idx != 0x00) {
const gchar *tmp; 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->report_id = HIDPP_REPORT_ID_SHORT;
msg->device_id = self->hidpp_id; msg->device_id = self->hidpp_id;
msg->sub_id = idx; msg->sub_id = idx;
msg->function_id = 0x02 << 4; /* getDeviceType */ msg->function_id = 0x02 << 4; /* getDeviceType */
msg->hidpp_version = self->hidpp_version; 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: "); g_prefix_error (error, "failed to get device type: ");
return FALSE; return FALSE;
} }
/* add nice-to-have data */ /* 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) if (tmp != NULL)
fu_device_set_summary (FU_DEVICE (device), tmp); 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) if (tmp != NULL)
fu_device_add_icon (FU_DEVICE (device), tmp); 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) { if (idx != 0x00) {
self->is_updatable = TRUE; self->is_updatable = TRUE;
fu_device_remove_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); 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) { if (idx != 0x00) {
/* check the feature is available */ /* 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->report_id = HIDPP_REPORT_ID_SHORT;
msg->device_id = self->hidpp_id; msg->device_id = self->hidpp_id;
msg->sub_id = idx; msg->sub_id = idx;
msg->function_id = 0x00 << 4; /* getDfuStatus */ msg->function_id = 0x00 << 4; /* getDfuStatus */
msg->hidpp_version = self->hidpp_version; 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: "); g_prefix_error (error, "failed to get DFU status: ");
return FALSE; 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); 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) { if (idx != 0x00) {
self->is_updatable = TRUE; self->is_updatable = TRUE;
fu_device_add_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); 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 */ /* 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 */ /* poll for pings to track active state */
fu_device_set_poll_interval (device, 30000); fu_device_set_poll_interval (device, 30000);
@ -610,14 +610,14 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error)
} }
static gboolean 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; guint8 idx;
g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new ();
/* this requires user action */ /* 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) { if (idx != 0x00) {
msg->report_id = HIDPP_REPORT_ID_LONG; msg->report_id = HIDPP_REPORT_ID_LONG;
msg->device_id = self->hidpp_id; 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->hidpp_version = self->hidpp_version;
msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID | msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID |
FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT; 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: "); g_prefix_error (error, "failed to put device into DFU mode: ");
return FALSE; return FALSE;
} }
@ -648,7 +648,7 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error)
} }
/* this can reboot all by itself */ /* 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) { if (idx != 0x00) {
msg->report_id = HIDPP_REPORT_ID_LONG; msg->report_id = HIDPP_REPORT_ID_LONG;
msg->device_id = self->hidpp_id; msg->device_id = self->hidpp_id;
@ -662,11 +662,11 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error)
msg->data[5] = 'F'; msg->data[5] = 'F';
msg->data[6] = 'U'; msg->data[6] = 'U';
msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID; 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: "); g_prefix_error (error, "failed to put device into DFU mode: ");
return FALSE; 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 */ /* we don't know how */
@ -678,7 +678,7 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error)
} }
static gboolean static gboolean
fu_unifying_peripheral_check_status (guint8 status, GError **error) fu_logitech_hidpp_peripheral_check_status (guint8 status, GError **error)
{ {
switch (status & 0x7f) { switch (status & 0x7f) {
case 0x00: case 0x00:
@ -824,14 +824,14 @@ fu_unifying_peripheral_check_status (guint8 status, GError **error)
} }
static gboolean static gboolean
fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self, fu_logitech_hidpp_peripheral_write_firmware_pkt (FuLogitechHidPpPeripheral *self,
guint8 idx, guint8 idx,
guint8 cmd, guint8 cmd,
const guint8 *data, const guint8 *data,
GError **error) GError **error)
{ {
guint32 packet_cnt; 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; g_autoptr(GError) error_local = NULL;
/* send firmware data */ /* send firmware data */
@ -841,7 +841,7 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self,
msg->function_id = cmd << 4; /* dfuStart or dfuCmdDataX */ msg->function_id = cmd << 4; /* dfuStart or dfuCmdDataX */
msg->hidpp_version = self->hidpp_version; msg->hidpp_version = self->hidpp_version;
memcpy (msg->data, data, 16); 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: "); g_prefix_error (error, "failed to supply program data: ");
return FALSE; return FALSE;
} }
@ -849,7 +849,7 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self,
/* check error */ /* check error */
packet_cnt = fu_common_read_uint32 (msg->data, G_BIG_ENDIAN); packet_cnt = fu_common_read_uint32 (msg->data, G_BIG_ENDIAN);
g_debug ("packet_cnt=0x%04x", packet_cnt); 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; return TRUE;
/* fatal error */ /* fatal error */
@ -866,13 +866,13 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self,
/* wait for the HID++ notification */ /* wait for the HID++ notification */
g_debug ("ignoring: %s", error_local->message); g_debug ("ignoring: %s", error_local->message);
for (guint retry = 0; retry < 10; retry++) { 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; 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; 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; 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); g_debug ("got %s, waiting a bit longer", error2->message);
continue; continue;
} }
@ -891,12 +891,12 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self,
} }
static gboolean static gboolean
fu_unifying_peripheral_write_firmware (FuDevice *device, fu_logitech_hidpp_peripheral_write_firmware (FuDevice *device,
FuFirmware *firmware, FuFirmware *firmware,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device);
gsize sz = 0; gsize sz = 0;
const guint8 *data; const guint8 *data;
guint8 cmd = 0x04; guint8 cmd = 0x04;
@ -904,7 +904,7 @@ fu_unifying_peripheral_write_firmware (FuDevice *device,
g_autoptr(GBytes) fw = NULL; g_autoptr(GBytes) fw = NULL;
/* if we're in bootloader mode, we should be able to get this feature */ /* 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) { if (idx == 0x00) {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
@ -925,7 +925,7 @@ fu_unifying_peripheral_write_firmware (FuDevice *device,
/* send packet and wait for reply */ /* send packet and wait for reply */
g_debug ("send data at addr=0x%04x", (guint) i * 16); 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, idx,
cmd, cmd,
data + (i * 16), data + (i * 16),
@ -947,14 +947,14 @@ fu_unifying_peripheral_write_firmware (FuDevice *device,
} }
static gboolean 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; 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 */ /* 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) { if (idx == 0x00) {
g_set_error (error, g_set_error (error,
G_IO_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 | msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID |
FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID | // inferred? FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID | // inferred?
FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT; 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: "); g_prefix_error (error, "failed to restart device: ");
return FALSE; return FALSE;
} }
/* reprobe */ /* reprobe */
if (!fu_unifying_peripheral_setup (device, error)) if (!fu_logitech_hidpp_peripheral_setup (device, error))
return FALSE; return FALSE;
/* success */ /* success */
@ -987,34 +987,34 @@ fu_unifying_peripheral_attach (FuDevice *device, GError **error)
} }
static void 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_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 static void
fu_unifying_peripheral_class_init (FuUnifyingPeripheralClass *klass) fu_logitech_hidpp_peripheral_class_init (FuLogitechHidPpPeripheralClass *klass)
{ {
FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass);
FuUdevDeviceClass *klass_device_udev = FU_UDEV_DEVICE_CLASS (klass); FuUdevDeviceClass *klass_device_udev = FU_UDEV_DEVICE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = fu_unifying_peripheral_finalize; object_class->finalize = fu_logitech_hidpp_peripheral_finalize;
klass_device->setup = fu_unifying_peripheral_setup; klass_device->setup = fu_logitech_hidpp_peripheral_setup;
klass_device->open = fu_unifying_peripheral_open; klass_device->open = fu_logitech_hidpp_peripheral_open;
klass_device->close = fu_unifying_peripheral_close; klass_device->close = fu_logitech_hidpp_peripheral_close;
klass_device->write_firmware = fu_unifying_peripheral_write_firmware; klass_device->write_firmware = fu_logitech_hidpp_peripheral_write_firmware;
klass_device->attach = fu_unifying_peripheral_attach; klass_device->attach = fu_logitech_hidpp_peripheral_attach;
klass_device->detach = fu_unifying_peripheral_detach; klass_device->detach = fu_logitech_hidpp_peripheral_detach;
klass_device->poll = fu_unifying_peripheral_poll; klass_device->poll = fu_logitech_hidpp_peripheral_poll;
klass_device->to_string = fu_unifying_peripheral_to_string; klass_device->to_string = fu_logitech_hidpp_peripheral_to_string;
klass_device_udev->probe = fu_unifying_peripheral_probe; klass_device_udev->probe = fu_logitech_hidpp_peripheral_probe;
} }
static void static void
fu_unifying_peripheral_init (FuUnifyingPeripheral *self) fu_logitech_hidpp_peripheral_init (FuLogitechHidPpPeripheral *self)
{ {
self->hidpp_id = HIDPP_DEVICE_ID_UNSET; self->hidpp_id = HIDPP_DEVICE_ID_UNSET;
self->feature_index = g_ptr_array_new_with_free_func (g_free); self->feature_index = g_ptr_array_new_with_free_func (g_free);

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 2017-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -8,11 +8,11 @@
#include <string.h> #include <string.h>
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-runtime.h" #include "fu-logitech-hidpp-runtime.h"
#include "fu-unifying-hidpp.h" #include "fu-logitech-hidpp-hidpp.h"
struct _FuUnifyingRuntime struct _FuLogitechHidPpRuntime
{ {
FuUdevDevice parent_instance; FuUdevDevice parent_instance;
guint8 version_bl_major; guint8 version_bl_major;
@ -20,19 +20,19 @@ struct _FuUnifyingRuntime
FuIOChannel *io_channel; 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 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); fu_common_string_append_kb (str, idt, "SignedFirmware", self->signed_firmware);
} }
static gboolean 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->report_id = HIDPP_REPORT_ID_SHORT;
msg->device_id = HIDPP_DEVICE_ID_RECEIVER; msg->device_id = HIDPP_DEVICE_ID_RECEIVER;
msg->sub_id = HIDPP_SUBID_SET_REGISTER; 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[1] = 0x05; /* Wireless + SoftwarePresent */
msg->data[2] = 0x00; msg->data[2] = 0x00;
msg->hidpp_version = 1; 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 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)) if (!fu_io_channel_shutdown (self->io_channel, error))
return FALSE; return FALSE;
g_clear_object (&self->io_channel); g_clear_object (&self->io_channel);
@ -55,12 +55,12 @@ fu_unifying_runtime_close (FuDevice *device, GError **error)
} }
static gboolean 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 */ const guint timeout = 1; /* ms */
g_autoptr(GError) error_local = NULL; 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; g_autoptr(FuDeviceLocker) locker = NULL;
/* open */ /* open */
@ -70,7 +70,7 @@ fu_unifying_runtime_poll (FuDevice *device, GError **error)
/* is there any pending data to read */ /* is there any pending data to read */
msg->hidpp_version = 1; 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, if (g_error_matches (error_local,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_TIMED_OUT)) { G_IO_ERROR_TIMED_OUT)) {
@ -81,7 +81,7 @@ fu_unifying_runtime_poll (FuDevice *device, GError **error)
} }
/* HID++1.0 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); g_warning ("failed to get pending read: %s", error_local->message);
return TRUE; return TRUE;
} }
@ -109,9 +109,9 @@ fu_unifying_runtime_poll (FuDevice *device, GError **error)
} }
static gboolean 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)); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (device));
const gchar *devpath = g_udev_device_get_device_file (udev_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 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)); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (device));
guint16 release = 0xffff; guint16 release = 0xffff;
g_autoptr(GUdevDevice) udev_parent = NULL; g_autoptr(GUdevDevice) udev_parent = NULL;
@ -176,16 +176,16 @@ fu_unifying_runtime_probe (FuUdevDevice *device, GError **error)
} }
static gboolean 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]; guint8 config[10];
g_autofree gchar *version_fw = NULL; g_autofree gchar *version_fw = NULL;
/* read all 10 bytes of the version register */ /* read all 10 bytes of the version register */
memset (config, 0x00, sizeof (config)); memset (config, 0x00, sizeof (config));
for (guint i = 0x01; i < 0x05; i++) { 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 /* workaround a bug in the 12.01 firmware, which fails with
* INVALID_VALUE when reading MCU1_HW_VERSION */ * 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->function_id = HIDPP_REGISTER_DEVICE_FIRMWARE_INFORMATION;
msg->data[0] = i; msg->data[0] = i;
msg->hidpp_version = 1; 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: "); g_prefix_error (error, "failed to read device config: ");
return FALSE; return FALSE;
} }
@ -209,7 +209,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error)
} }
/* get firmware version */ /* get firmware version */
version_fw = fu_unifying_format_version ("RQR", version_fw = fu_logitech_hidpp_format_version ("RQR",
config[2], config[2],
config[3], config[3],
(guint16) config[4] << 8 | (guint16) config[4] << 8 |
@ -219,7 +219,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error)
/* get bootloader version */ /* get bootloader version */
if (self->version_bl_major > 0) { if (self->version_bl_major > 0) {
g_autofree gchar *version_bl = NULL; 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, self->version_bl_major,
config[8], config[8],
config[9]); config[9]);
@ -233,7 +233,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error)
} }
/* enable HID++ notifications */ /* 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: "); g_prefix_error (error, "failed to enable notifications: ");
return FALSE; return FALSE;
} }
@ -243,7 +243,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error)
} }
static gboolean 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; g_autoptr(GError) error_local = NULL;
for (guint i = 0; i < 5; i++) { 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 * the device first -- we can't use the SwID as this is a
* HID++2.0 feature */ * HID++2.0 feature */
g_usleep (200*1000); 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; return TRUE;
if (!g_error_matches (error_local, if (!g_error_matches (error_local,
G_IO_ERROR, G_IO_ERROR,
@ -266,10 +266,10 @@ fu_unifying_runtime_setup (FuDevice *device, GError **error)
} }
static gboolean 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); FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device);
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->report_id = HIDPP_REPORT_ID_SHORT;
msg->device_id = HIDPP_DEVICE_ID_RECEIVER; msg->device_id = HIDPP_DEVICE_ID_RECEIVER;
msg->sub_id = HIDPP_SUBID_SET_REGISTER; msg->sub_id = HIDPP_SUBID_SET_REGISTER;
@ -279,7 +279,7 @@ fu_unifying_runtime_detach (FuDevice *device, GError **error)
msg->data[2] = 'P'; msg->data[2] = 'P';
msg->hidpp_version = 1; msg->hidpp_version = 1;
msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT; 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: "); g_prefix_error (error, "failed to detach to bootloader: ");
return FALSE; return FALSE;
} }
@ -288,30 +288,30 @@ fu_unifying_runtime_detach (FuDevice *device, GError **error)
} }
static void 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 static void
fu_unifying_runtime_class_init (FuUnifyingRuntimeClass *klass) fu_logitech_hidpp_runtime_class_init (FuLogitechHidPpRuntimeClass *klass)
{ {
FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass);
FuUdevDeviceClass *klass_device_udev = FU_UDEV_DEVICE_CLASS (klass); FuUdevDeviceClass *klass_device_udev = FU_UDEV_DEVICE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = fu_unifying_runtime_finalize; object_class->finalize = fu_logitech_hidpp_runtime_finalize;
klass_device->open = fu_unifying_runtime_open; klass_device->open = fu_logitech_hidpp_runtime_open;
klass_device_udev->probe = fu_unifying_runtime_probe; klass_device_udev->probe = fu_logitech_hidpp_runtime_probe;
klass_device->setup = fu_unifying_runtime_setup; klass_device->setup = fu_logitech_hidpp_runtime_setup;
klass_device->close = fu_unifying_runtime_close; klass_device->close = fu_logitech_hidpp_runtime_close;
klass_device->detach = fu_unifying_runtime_detach; klass_device->detach = fu_logitech_hidpp_runtime_detach;
klass_device->poll = fu_unifying_runtime_poll; klass_device->poll = fu_logitech_hidpp_runtime_poll;
klass_device->to_string = fu_unifying_runtime_to_string; klass_device->to_string = fu_logitech_hidpp_runtime_to_string;
} }
static void 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_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_icon (FU_DEVICE (self), "preferences-desktop-keyboard"); fu_device_add_icon (FU_DEVICE (self), "preferences-desktop-keyboard");

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -9,21 +9,21 @@
#include <fwupd.h> #include <fwupd.h>
#include <glib-object.h> #include <glib-object.h>
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
static void static void
fu_unifying_common (void) fu_logitech_hidpp_common (void)
{ {
guint8 u8; guint8 u8;
guint16 u16; guint16 u16;
g_autofree gchar *ver1 = NULL; 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); 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); 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"); 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); g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
/* tests go here */ /* 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 (); return g_test_run ();
} }

View File

@ -10,11 +10,11 @@
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-unifying-bootloader-nordic.h" #include "fu-logitech-hidpp-bootloader-nordic.h"
#include "fu-unifying-bootloader-texas.h" #include "fu-logitech-hidpp-bootloader-texas.h"
#include "fu-unifying-common.h" #include "fu-logitech-hidpp-common.h"
#include "fu-unifying-peripheral.h" #include "fu-logitech-hidpp-peripheral.h"
#include "fu-unifying-runtime.h" #include "fu-logitech-hidpp-runtime.h"
gboolean gboolean
fu_plugin_startup (FuPlugin *plugin, GError **error) fu_plugin_startup (FuPlugin *plugin, GError **error)

View File

@ -1,43 +1,43 @@
# Unifying Receiver # Unifying Receiver
[DeviceInstanceId=HIDRAW\VEN_046D&DEV_C52B] [DeviceInstanceId=HIDRAW\VEN_046D&DEV_C52B]
Plugin = unifying Plugin = logitech_hidpp
GType = FuUnifyingRuntime GType = FuLogitechHidPpRuntime
VendorId=USB:0x046D VendorId=USB:0x046D
InstallDuration = 30 InstallDuration = 30
# Nordic # Nordic
[DeviceInstanceId=USB\VID_046D&PID_AAAA] [DeviceInstanceId=USB\VID_046D&PID_AAAA]
Plugin = unifying Plugin = logitech_hidpp
GType = FuUnifyingBootloaderNordic GType = FuLogitechHidPpBootloaderNordic
FirmwareSizeMin = 0x4000 FirmwareSizeMin = 0x4000
CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B
InstallDuration = 30 InstallDuration = 30
# Nordic Pico # Nordic Pico
[DeviceInstanceId=USB\VID_046D&PID_AAAE] [DeviceInstanceId=USB\VID_046D&PID_AAAE]
Plugin = unifying Plugin = logitech_hidpp
GType = FuUnifyingBootloaderNordic GType = FuLogitechHidPpBootloaderNordic
FirmwareSizeMin = 0x4000 FirmwareSizeMin = 0x4000
CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B
InstallDuration = 30 InstallDuration = 30
# Texas # Texas
[DeviceInstanceId=USB\VID_046D&PID_AAAC] [DeviceInstanceId=USB\VID_046D&PID_AAAC]
Plugin = unifying Plugin = logitech_hidpp
GType = FuUnifyingBootloaderTexas GType = FuLogitechHidPpBootloaderTexas
FirmwareSizeMin = 0x4000 FirmwareSizeMin = 0x4000
CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B
InstallDuration = 18 InstallDuration = 18
# Texas Pico # Texas Pico
[DeviceInstanceId=USB\VID_046D&PID_AAAD] [DeviceInstanceId=USB\VID_046D&PID_AAAD]
Plugin = unifying Plugin = logitech_hidpp
GType = FuUnifyingBootloaderTexas GType = FuLogitechHidPpBootloaderTexas
FirmwareSizeMin = 0x4000 FirmwareSizeMin = 0x4000
CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B
InstallDuration = 18 InstallDuration = 18
# Possible HID++ v2.0 peripheral device # Possible HID++ v2.0 peripheral device
[DeviceInstanceId=HIDRAW\VEN_046D] [DeviceInstanceId=HIDRAW\VEN_046D]
Plugin = unifying Plugin = logitech_hidpp
GType = FuUnifyingPeripheral GType = FuLogitechHidPpPeripheral

View File

@ -1,24 +1,24 @@
cargs = ['-DG_LOG_DOMAIN="FuPluginUnifying"'] cargs = ['-DG_LOG_DOMAIN="FuPluginLogitechHidPp"']
install_data([ install_data([
'unifying.quirk', 'logitech-hidpp.quirk',
], ],
install_dir: join_paths(datadir, 'fwupd', 'quirks.d') install_dir: join_paths(datadir, 'fwupd', 'quirks.d')
) )
shared_module('fu_plugin_unifying', shared_module('fu_plugin_logitech_hidpp',
fu_hash, fu_hash,
sources : [ sources : [
'fu-plugin-unifying.c', 'fu-plugin-logitech-hidpp.c',
'fu-unifying-bootloader.c', 'fu-logitech-hidpp-bootloader.c',
'fu-unifying-bootloader-nordic.c', 'fu-logitech-hidpp-bootloader-nordic.c',
'fu-unifying-bootloader-texas.c', 'fu-logitech-hidpp-bootloader-texas.c',
'fu-unifying-common.c', 'fu-logitech-hidpp-common.c',
'fu-unifying-hidpp.c', 'fu-logitech-hidpp-hidpp.c',
'fu-unifying-hidpp-msg.c', 'fu-logitech-hidpp-hidpp-msg.c',
'fu-unifying-peripheral.c', 'fu-logitech-hidpp-peripheral.c',
'fu-unifying-runtime.c', 'fu-logitech-hidpp-runtime.c',
], ],
include_directories : [ include_directories : [
include_directories('../..'), include_directories('../..'),
@ -38,11 +38,11 @@ shared_module('fu_plugin_unifying',
if get_option('tests') if get_option('tests')
e = executable( e = executable(
'unifying-self-test', 'logitech-hidpp-self-test',
fu_hash, fu_hash,
sources : [ sources : [
'fu-unifying-self-test.c', 'fu-logitech-hidpp-self-test.c',
'fu-unifying-common.c', 'fu-logitech-hidpp-common.c',
], ],
include_directories : [ include_directories : [
include_directories('../..'), include_directories('../..'),
@ -56,5 +56,5 @@ if get_option('tests')
], ],
c_args : cargs, c_args : cargs,
) )
test('unifying-self-test', e) test('logitech-hidpp-self-test', e)
endif endif

View File

@ -7,6 +7,7 @@ subdir('fastboot')
subdir('jabra') subdir('jabra')
subdir('steelseries') subdir('steelseries')
subdir('dell-dock') subdir('dell-dock')
subdir('logitech-hidpp')
subdir('nitrokey') subdir('nitrokey')
subdir('optionrom') subdir('optionrom')
subdir('rts54hid') subdir('rts54hid')
@ -16,7 +17,6 @@ subdir('synaptics-cxaudio')
subdir('synaptics-prometheus') subdir('synaptics-prometheus')
subdir('test') subdir('test')
subdir('thelio-io') subdir('thelio-io')
subdir('unifying')
subdir('upower') subdir('upower')
subdir('wacom-raw') subdir('wacom-raw')
subdir('wacom-usb') subdir('wacom-usb')

View File

@ -1,12 +0,0 @@
/*
* Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -1,12 +0,0 @@
/*
* Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2017-2018 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib.h>
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);

View File

@ -1,12 +0,0 @@
/*
* Copyright (C) 2017-2018 Richard Hughes <richard@hughsie.com>
*
* 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)

View File

@ -1,12 +0,0 @@
/*
* Copyright (C) 2016-2018 Richard Hughes <richard@hughsie.com>
*
* 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)