From 0012853a1d95a0722cd51e2bf680a6b99c70f89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Tue, 28 Jan 2020 15:10:17 +0000 Subject: [PATCH] hidpp20: make sure getZoneEffect (8070) is supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe LaĆ­ns --- src/hidpp20.c | 7 +++++++ src/hidpp20.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/hidpp20.c b/src/hidpp20.c index 42f25e7a..11300326 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -895,6 +895,7 @@ hidpp20_color_led_effects_get_info(struct hidpp20_device *device, return rc; *info = *(struct hidpp20_color_led_info *)msg.msg.parameters; + device->led_ext_caps = info->ext_caps; return 0; } @@ -1061,6 +1062,10 @@ hidpp20_color_led_effects_get_zone_effect(struct hidpp20_device *device, struct hidpp20_internal_led *internal_led; int rc; + /* hidpp20_color_led_effects_get_info() must be called first to set the capabilities */ + if (!(device->led_ext_caps & HIDPP20_COLOR_LED_INFO_EXT_CAP_HAS_ZONE_EFFECT)) + return -ENOTSUP; + feature_index = hidpp_root_get_feature_idx(device, HIDPP_PAGE_COLOR_LED_EFFECTS); if (feature_index == 0) @@ -3022,6 +3027,8 @@ hidpp20_device_new(const struct hidpp_device *base, unsigned int idx, struct hid dev->proto_major = 1; dev->proto_minor = 0; + dev->led_ext_caps = 0; + hidpp_get_supported_report_types(&(dev->base), reports, num_reports); if (!(dev->base.supported_report_types & HIDPP_REPORT_SHORT) && diff --git a/src/hidpp20.h b/src/hidpp20.h index ffe37102..de370629 100644 --- a/src/hidpp20.h +++ b/src/hidpp20.h @@ -65,6 +65,7 @@ struct hidpp20_device { unsigned feature_count; struct hidpp20_feature *feature_list; enum hidpp20_quirk quirk; + unsigned int led_ext_caps; }; int hidpp20_request_command(struct hidpp20_device *dev, union hidpp20_message *msg);