mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-16 06:09:07 +00:00
wacom-usb: Use the device proxy functionality
The wacom-usb plugin was created in a simpler time, before we had the concept of `FuDevice.proxy`. Switch to the shared code to modernize the code, and also because setting the proxy conveys other semantics that we need to emulate the device successfully in the future.
This commit is contained in:
parent
7a2207fb28
commit
d064cc740e
@ -668,7 +668,6 @@ fu_wac_device_write_firmware(FuDevice *device,
|
||||
static gboolean
|
||||
fu_wac_device_add_modules_bluetooth(FuWacDevice *self, GError **error)
|
||||
{
|
||||
GUsbDevice *usb_device = fu_usb_device_get_dev(FU_USB_DEVICE(self));
|
||||
g_autofree gchar *name = NULL;
|
||||
g_autofree gchar *name_id6 = NULL;
|
||||
g_autoptr(FuWacModule) module = NULL;
|
||||
@ -699,15 +698,14 @@ fu_wac_device_add_modules_bluetooth(FuWacDevice *self, GError **error)
|
||||
* package.
|
||||
*/
|
||||
name = g_strdup_printf("%s [Legacy Bluetooth Module]", fu_device_get_name(FU_DEVICE(self)));
|
||||
module = fu_wac_module_bluetooth_new(fu_device_get_context(FU_DEVICE(self)), usb_device);
|
||||
module = fu_wac_module_bluetooth_new(FU_DEVICE(self));
|
||||
fu_device_add_child(FU_DEVICE(self), FU_DEVICE(module));
|
||||
fu_device_set_name(FU_DEVICE(module), name);
|
||||
fu_device_set_version_from_uint16(FU_DEVICE(module), fw_ver);
|
||||
|
||||
name_id6 = g_strdup_printf("%s [Legacy Bluetooth Module (ID6)]",
|
||||
fu_device_get_name(FU_DEVICE(self)));
|
||||
module_id6 =
|
||||
fu_wac_module_bluetooth_id6_new(fu_device_get_context(FU_DEVICE(self)), usb_device);
|
||||
module_id6 = fu_wac_module_bluetooth_id6_new(FU_DEVICE(self));
|
||||
fu_device_add_child(FU_DEVICE(self), FU_DEVICE(module_id6));
|
||||
fu_device_set_name(FU_DEVICE(module_id6), name_id6);
|
||||
fu_device_set_version_from_uint16(FU_DEVICE(module_id6), fw_ver);
|
||||
@ -729,7 +727,6 @@ fu_wac_device_add_modules_legacy(FuWacDevice *self, GError **error)
|
||||
static gboolean
|
||||
fu_wac_device_add_modules(FuWacDevice *self, GError **error)
|
||||
{
|
||||
GUsbDevice *usb_device = fu_usb_device_get_dev(FU_USB_DEVICE(self));
|
||||
g_autofree gchar *version_bootloader = NULL;
|
||||
guint8 buf[] = {[0] = FU_WAC_REPORT_ID_FW_DESCRIPTOR, [1 ... 31] = 0xff};
|
||||
guint16 boot_ver;
|
||||
@ -785,8 +782,7 @@ fu_wac_device_add_modules(FuWacDevice *self, GError **error)
|
||||
|
||||
switch (fw_type) {
|
||||
case FU_WAC_MODULE_FW_TYPE_TOUCH:
|
||||
module = fu_wac_module_touch_new(fu_device_get_context(FU_DEVICE(self)),
|
||||
usb_device);
|
||||
module = fu_wac_module_touch_new(FU_DEVICE(self));
|
||||
name = g_strdup_printf("%s [Touch Module]",
|
||||
fu_device_get_name(FU_DEVICE(self)));
|
||||
fu_device_add_child(FU_DEVICE(self), FU_DEVICE(module));
|
||||
@ -794,8 +790,7 @@ fu_wac_device_add_modules(FuWacDevice *self, GError **error)
|
||||
fu_device_set_version_from_uint16(FU_DEVICE(module), ver);
|
||||
break;
|
||||
case FU_WAC_MODULE_FW_TYPE_BLUETOOTH:
|
||||
module = fu_wac_module_bluetooth_new(fu_device_get_context(FU_DEVICE(self)),
|
||||
usb_device);
|
||||
module = fu_wac_module_bluetooth_new(FU_DEVICE(self));
|
||||
name = g_strdup_printf("%s [Bluetooth Module]",
|
||||
fu_device_get_name(FU_DEVICE(self)));
|
||||
fu_device_add_child(FU_DEVICE(self), FU_DEVICE(module));
|
||||
@ -803,9 +798,7 @@ fu_wac_device_add_modules(FuWacDevice *self, GError **error)
|
||||
fu_device_set_version_from_uint16(FU_DEVICE(module), ver);
|
||||
break;
|
||||
case FU_WAC_MODULE_FW_TYPE_BLUETOOTH_ID6:
|
||||
module =
|
||||
fu_wac_module_bluetooth_id6_new(fu_device_get_context(FU_DEVICE(self)),
|
||||
usb_device);
|
||||
module = fu_wac_module_bluetooth_id6_new(FU_DEVICE(self));
|
||||
name = g_strdup_printf("%s [Bluetooth Module (ID6)]",
|
||||
fu_device_get_name(FU_DEVICE(self)));
|
||||
fu_device_add_child(FU_DEVICE(self), FU_DEVICE(module));
|
||||
@ -813,8 +806,7 @@ fu_wac_device_add_modules(FuWacDevice *self, GError **error)
|
||||
fu_device_set_version_from_uint16(FU_DEVICE(module), ver);
|
||||
break;
|
||||
case FU_WAC_MODULE_FW_TYPE_SCALER:
|
||||
module = fu_wac_module_scaler_new(fu_device_get_context(FU_DEVICE(self)),
|
||||
usb_device);
|
||||
module = fu_wac_module_scaler_new(FU_DEVICE(self));
|
||||
name = g_strdup_printf("%s [Scaler Module]",
|
||||
fu_device_get_name(FU_DEVICE(self)));
|
||||
fu_device_add_child(FU_DEVICE(self), FU_DEVICE(module));
|
||||
|
@ -197,14 +197,12 @@ fu_wac_module_bluetooth_id6_class_init(FuWacModuleBluetoothId6Class *klass)
|
||||
}
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_bluetooth_id6_new(FuContext *context, GUsbDevice *usb_device)
|
||||
fu_wac_module_bluetooth_id6_new(FuDevice *proxy)
|
||||
{
|
||||
FuWacModule *module = NULL;
|
||||
module = g_object_new(FU_TYPE_WAC_MODULE_BLUETOOTH_ID6,
|
||||
"context",
|
||||
context,
|
||||
"usb-device",
|
||||
usb_device,
|
||||
"proxy",
|
||||
proxy,
|
||||
"fw-type",
|
||||
FU_WAC_MODULE_FW_TYPE_BLUETOOTH_ID6,
|
||||
NULL);
|
||||
|
@ -17,4 +17,4 @@ G_DECLARE_FINAL_TYPE(FuWacModuleBluetoothId6,
|
||||
FuWacModule)
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_bluetooth_id6_new(FuContext *context, GUsbDevice *usb_device);
|
||||
fu_wac_module_bluetooth_id6_new(FuDevice *proxy);
|
||||
|
@ -222,14 +222,12 @@ fu_wac_module_bluetooth_class_init(FuWacModuleBluetoothClass *klass)
|
||||
}
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_bluetooth_new(FuContext *context, GUsbDevice *usb_device)
|
||||
fu_wac_module_bluetooth_new(FuDevice *proxy)
|
||||
{
|
||||
FuWacModule *module = NULL;
|
||||
module = g_object_new(FU_TYPE_WAC_MODULE_BLUETOOTH,
|
||||
"context",
|
||||
context,
|
||||
"usb-device",
|
||||
usb_device,
|
||||
"proxy",
|
||||
proxy,
|
||||
"fw-type",
|
||||
FU_WAC_MODULE_FW_TYPE_BLUETOOTH,
|
||||
NULL);
|
||||
|
@ -16,4 +16,4 @@ G_DECLARE_FINAL_TYPE(FuWacModuleBluetooth,
|
||||
FuWacModule)
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_bluetooth_new(FuContext *context, GUsbDevice *usb_device);
|
||||
fu_wac_module_bluetooth_new(FuDevice *proxy);
|
||||
|
@ -170,14 +170,12 @@ fu_wac_module_scaler_class_init(FuWacModuleScalerClass *klass)
|
||||
}
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_scaler_new(FuContext *context, GUsbDevice *usb_device)
|
||||
fu_wac_module_scaler_new(FuDevice *proxy)
|
||||
{
|
||||
FuWacModule *module = NULL;
|
||||
module = g_object_new(FU_TYPE_WAC_MODULE_SCALER,
|
||||
"context",
|
||||
context,
|
||||
"usb-device",
|
||||
usb_device,
|
||||
"proxy",
|
||||
proxy,
|
||||
"fw-type",
|
||||
FU_WAC_MODULE_FW_TYPE_SCALER,
|
||||
NULL);
|
||||
|
@ -13,4 +13,4 @@
|
||||
G_DECLARE_FINAL_TYPE(FuWacModuleScaler, fu_wac_module_scaler, FU, WAC_MODULE_SCALER, FuWacModule)
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_scaler_new(FuContext *context, GUsbDevice *usb_device);
|
||||
fu_wac_module_scaler_new(FuDevice *proxy);
|
||||
|
@ -135,14 +135,12 @@ fu_wac_module_touch_class_init(FuWacModuleTouchClass *klass)
|
||||
}
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_touch_new(FuContext *context, GUsbDevice *usb_device)
|
||||
fu_wac_module_touch_new(FuDevice *proxy)
|
||||
{
|
||||
FuWacModule *module = NULL;
|
||||
module = g_object_new(FU_TYPE_WAC_MODULE_TOUCH,
|
||||
"context",
|
||||
context,
|
||||
"usb-device",
|
||||
usb_device,
|
||||
"proxy",
|
||||
proxy,
|
||||
"fw-type",
|
||||
FU_WAC_MODULE_FW_TYPE_TOUCH,
|
||||
NULL);
|
||||
|
@ -12,4 +12,4 @@
|
||||
G_DECLARE_FINAL_TYPE(FuWacModuleTouch, fu_wac_module_touch, FU, WAC_MODULE_TOUCH, FuWacModule)
|
||||
|
||||
FuWacModule *
|
||||
fu_wac_module_touch_new(FuContext *context, GUsbDevice *usb_device);
|
||||
fu_wac_module_touch_new(FuDevice *proxy);
|
||||
|
@ -29,7 +29,6 @@
|
||||
#define FU_WAC_MODULE_STATUS_ERR_WRONG_IMAGE 14
|
||||
|
||||
typedef struct {
|
||||
GUsbDevice *usb_device;
|
||||
guint8 fw_type;
|
||||
guint8 command;
|
||||
guint8 status;
|
||||
@ -38,7 +37,7 @@ typedef struct {
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(FuWacModule, fu_wac_module, FU_TYPE_DEVICE)
|
||||
#define GET_PRIVATE(o) (fu_wac_module_get_instance_private(o))
|
||||
|
||||
enum { PROP_0, PROP_FW_TYPE, PROP_USB_DEVICE, PROP_LAST };
|
||||
enum { PROP_0, PROP_FW_TYPE, PROP_LAST };
|
||||
|
||||
static const gchar *
|
||||
fu_wac_module_fw_type_to_string(guint8 fw_type)
|
||||
@ -278,9 +277,6 @@ fu_wac_module_get_property(GObject *object, guint prop_id, GValue *value, GParam
|
||||
case PROP_FW_TYPE:
|
||||
g_value_set_uint(value, priv->fw_type);
|
||||
break;
|
||||
case PROP_USB_DEVICE:
|
||||
g_value_set_object(value, priv->usb_device);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -296,9 +292,6 @@ fu_wac_module_set_property(GObject *object, guint prop_id, const GValue *value,
|
||||
case PROP_FW_TYPE:
|
||||
priv->fw_type = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_USB_DEVICE:
|
||||
g_set_object(&priv->usb_device, g_value_get_object(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -319,21 +312,22 @@ fu_wac_module_constructed(GObject *object)
|
||||
{
|
||||
FuWacModule *self = FU_WAC_MODULE(object);
|
||||
FuWacModulePrivate *priv = GET_PRIVATE(self);
|
||||
FuDevice *proxy = fu_device_get_proxy(FU_DEVICE(self));
|
||||
g_autofree gchar *devid = NULL;
|
||||
g_autofree gchar *vendor_id = NULL;
|
||||
|
||||
/* set vendor ID */
|
||||
vendor_id = g_strdup_printf("USB:0x%04X", g_usb_device_get_vid(priv->usb_device));
|
||||
vendor_id = g_strdup_printf("USB:0x%04X", fu_usb_device_get_vid(FU_USB_DEVICE(proxy)));
|
||||
fu_device_add_vendor_id(FU_DEVICE(self), vendor_id);
|
||||
|
||||
/* set USB physical and logical IDs */
|
||||
fu_device_set_physical_id(FU_DEVICE(self), g_usb_device_get_platform_id(priv->usb_device));
|
||||
fu_device_set_physical_id(FU_DEVICE(self), fu_device_get_physical_id(proxy));
|
||||
fu_device_set_logical_id(FU_DEVICE(self), fu_wac_module_fw_type_to_string(priv->fw_type));
|
||||
|
||||
/* append the firmware kind to the generated GUID */
|
||||
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X-%s",
|
||||
g_usb_device_get_vid(priv->usb_device),
|
||||
g_usb_device_get_pid(priv->usb_device),
|
||||
fu_usb_device_get_vid(FU_USB_DEVICE(proxy)),
|
||||
fu_usb_device_get_pid(FU_USB_DEVICE(proxy)),
|
||||
fu_wac_module_fw_type_to_string(priv->fw_type));
|
||||
fu_device_add_instance_id(FU_DEVICE(self), devid);
|
||||
|
||||
@ -350,16 +344,6 @@ fu_wac_module_set_progress(FuDevice *self, FuProgress *progress)
|
||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 0, "reload");
|
||||
}
|
||||
|
||||
static void
|
||||
fu_wac_module_finalize(GObject *object)
|
||||
{
|
||||
FuWacModule *self = FU_WAC_MODULE(object);
|
||||
FuWacModulePrivate *priv = GET_PRIVATE(self);
|
||||
if (priv->usb_device != NULL)
|
||||
g_object_unref(priv->usb_device);
|
||||
G_OBJECT_CLASS(fu_wac_module_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
fu_wac_module_class_init(FuWacModuleClass *klass)
|
||||
{
|
||||
@ -371,18 +355,6 @@ fu_wac_module_class_init(FuWacModuleClass *klass)
|
||||
object_class->get_property = fu_wac_module_get_property;
|
||||
object_class->set_property = fu_wac_module_set_property;
|
||||
|
||||
/**
|
||||
* FuWacModule:usb-device:
|
||||
*
|
||||
* The parent USB device to use.
|
||||
*/
|
||||
pspec = g_param_spec_object("usb-device",
|
||||
NULL,
|
||||
NULL,
|
||||
G_USB_TYPE_DEVICE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_NAME);
|
||||
g_object_class_install_property(object_class, PROP_USB_DEVICE, pspec);
|
||||
|
||||
/**
|
||||
* FuWacModule:fw-type:
|
||||
*
|
||||
@ -398,7 +370,6 @@ fu_wac_module_class_init(FuWacModuleClass *klass)
|
||||
g_object_class_install_property(object_class, PROP_FW_TYPE, pspec);
|
||||
|
||||
object_class->constructed = fu_wac_module_constructed;
|
||||
object_class->finalize = fu_wac_module_finalize;
|
||||
klass_device->to_string = fu_wac_module_to_string;
|
||||
klass_device->cleanup = fu_wac_module_cleanup;
|
||||
klass_device->set_progress = fu_wac_module_set_progress;
|
||||
|
Loading…
Reference in New Issue
Block a user