linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 2/2] HID: logitech: Support WirelessDeviceStatus connect events
@ 2019-10-11 17:47 Mazin Rezk
  2019-10-14  3:46 ` kbuild test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Mazin Rezk @ 2019-10-11 17:47 UTC (permalink / raw)
  To: linux-input
  Cc: benjamin.tissoires, jikos, linux-kernel, Filipe Laíns, mnrzk

This patch allows WirelessDeviceStatus (0x1d4b) events to be detected as
connection events in the hid-logitech-hidpp module.

Devices with HIDPP_QUIRK_WIRELESS_DEVICE_STATUS use WirelessDeviceStatus
instead of traditional connect events. Since all Bluetooth LE devices seem
to act this way, HIDPP_QUIRK_CLASS_BLUETOOTH_LE aliases this quirk.

Signed-off-by: Mazin Rezk <mnrzk@protonmail.com>
---
 drivers/hid/hid-logitech-hidpp.c | 42 ++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 3692fb883602..0dfa9b22b536 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -72,6 +72,7 @@ MODULE_PARM_DESC(disable_tap_to_click,
 #define HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS	BIT(30)
 #define HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS	BIT(31)
 #define HIDPP_QUIRK_MISSING_SHORT_REPORTS	BIT(32)
+#define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS	BIT(33)

 /* These are just aliases for now */
 #define HIDPP_QUIRK_KBD_SCROLL_WHEEL HIDPP_QUIRK_HIDPP_WHEELS
@@ -82,7 +83,8 @@ MODULE_PARM_DESC(disable_tap_to_click,
 					 HIDPP_QUIRK_HI_RES_SCROLL_X2120 | \
 					 HIDPP_QUIRK_HI_RES_SCROLL_X2121)

-#define HIDPP_QUIRK_CLASS_BLUETOOTH_LE	HIDPP_QUIRK_MISSING_SHORT_REPORTS
+#define HIDPP_QUIRK_CLASS_BLUETOOTH_LE	(HIDPP_QUIRK_MISSING_SHORT_REPORTS | \
+					 HIDPP_QUIRK_WIRELESS_DEVICE_STATUS)

 #define HIDPP_QUIRK_DELAYED_INIT		HIDPP_QUIRK_NO_HIDINPUT

@@ -189,6 +191,8 @@ struct hidpp_device {

 	struct hidpp_battery battery;
 	struct hidpp_scroll_counter vertical_wheel_counter;
+
+	u8 wireless_feature_index;
 };

 /* HID++ 1.0 error codes */
@@ -402,10 +406,14 @@ static inline bool hidpp_match_error(struct hidpp_report *question,
 	    (answer->fap.params[0] == question->fap.funcindex_clientid);
 }

-static inline bool hidpp_report_is_connect_event(struct hidpp_report *report)
+static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp,
+						 struct hidpp_report *report)
 {
-	return (report->report_id == REPORT_ID_HIDPP_SHORT) &&
-		(report->rap.sub_id == 0x41);
+	return ((hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) &&
+		(report->fap.feature_index == hidpp->wireless_feature_index)) ||
+	      (((report->report_id == REPORT_ID_HIDPP_SHORT) ||
+		(hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) &&
+		(report->rap.sub_id == 0x41));
 }

 /**
@@ -1282,6 +1290,24 @@ static int hidpp_battery_get_property(struct power_supply *psy,
 	return ret;
 }

+/* -------------------------------------------------------------------------- */
+/* 0x1d4b: Wireless device status                                             */
+/* -------------------------------------------------------------------------- */
+#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS			0x1d4b
+
+static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp)
+{
+	u8 feature_type;
+	int ret;
+
+	ret = hidpp_root_get_feature(hidpp,
+				     HIDPP_PAGE_WIRELESS_DEVICE_STATUS,
+				     &hidpp->wireless_feature_index,
+				     &feature_type);
+
+	return ret;
+}
+
 /* -------------------------------------------------------------------------- */
 /* 0x2120: Hi-resolution scrolling                                            */
 /* -------------------------------------------------------------------------- */
@@ -3077,7 +3103,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
 		}
 	}

-	if (unlikely(hidpp_report_is_connect_event(report))) {
+	if (unlikely(hidpp_report_is_connect_event(hidpp, report))) {
 		atomic_set(&hidpp->connected,
 				!(report->rap.params[0] & (1 << 6)));
 		if (schedule_work(&hidpp->work) == 0)
@@ -3624,6 +3650,12 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		hidpp_overwrite_name(hdev);
 	}

+	if (connected && (hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS)) {
+		ret = hidpp_set_wireless_feature_index(hidpp);
+		if (ret)
+			goto hid_hw_init_fail;
+	}
+
 	if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) {
 		ret = wtp_get_config(hidpp);
 		if (ret)
--
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v5 2/2] HID: logitech: Support WirelessDeviceStatus connect events
  2019-10-11 17:47 [PATCH v5 2/2] HID: logitech: Support WirelessDeviceStatus connect events Mazin Rezk
@ 2019-10-14  3:46 ` kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2019-10-14  3:46 UTC (permalink / raw)
  To: Mazin Rezk
  Cc: kbuild-all, linux-input, benjamin.tissoires, jikos, linux-kernel,
	Filipe Laíns, mnrzk

[-- Attachment #1: Type: text/plain, Size: 8070 bytes --]

Hi Mazin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc2 next-20191010]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Mazin-Rezk/HID-logitech-Add-MX-Master-over-Bluetooth/20191014-071534
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/ioport.h:15:0,
                    from include/linux/device.h:15,
                    from drivers/hid/hid-logitech-hidpp.c:13:
   drivers/hid/hid-logitech-hidpp.c: In function 'hidpp_send_rap_command_sync':
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:74:43: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_MISSING_SHORT_REPORTS BIT(32)
                                              ^~~
   drivers/hid/hid-logitech-hidpp.c:351:26: note: in expansion of macro 'HIDPP_QUIRK_MISSING_SHORT_REPORTS'
     if (hidpp_dev->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS &&
                             ^
   drivers/hid/hid-logitech-hidpp.c: In function 'hidpp_report_is_connect_event':
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:75:44: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS BIT(33)
                                               ^~~
>> drivers/hid/hid-logitech-hidpp.c:412:27: note: in expansion of macro 'HIDPP_QUIRK_WIRELESS_DEVICE_STATUS'
     return ((hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) &&
                              ^
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:74:43: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_MISSING_SHORT_REPORTS BIT(32)
                                              ^~~
   drivers/hid/hid-logitech-hidpp.c:415:20: note: in expansion of macro 'HIDPP_QUIRK_MISSING_SHORT_REPORTS'
      (hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) &&
                       ^
   drivers/hid/hid-logitech-hidpp.c: In function 'hidpp_validate_device':
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:74:43: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_MISSING_SHORT_REPORTS BIT(32)
                                              ^~~
   drivers/hid/hid-logitech-hidpp.c:3522:22: note: in expansion of macro 'HIDPP_QUIRK_MISSING_SHORT_REPORTS'
     if (hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)
                         ^
   drivers/hid/hid-logitech-hidpp.c: In function 'hidpp_probe':
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:75:44: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS BIT(33)
                                               ^~~
   drivers/hid/hid-logitech-hidpp.c:3653:36: note: in expansion of macro 'HIDPP_QUIRK_WIRELESS_DEVICE_STATUS'
     if (connected && (hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS)) {
                                       ^
   drivers/hid/hid-logitech-hidpp.c: At top level:
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:74:43: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_MISSING_SHORT_REPORTS BIT(32)
                                              ^~~
   drivers/hid/hid-logitech-hidpp.c:86:41: note: in expansion of macro 'HIDPP_QUIRK_MISSING_SHORT_REPORTS'
    #define HIDPP_QUIRK_CLASS_BLUETOOTH_LE (HIDPP_QUIRK_MISSING_SHORT_REPORTS | \
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-logitech-hidpp.c:3826:5: note: in expansion of macro 'HIDPP_QUIRK_CLASS_BLUETOOTH_LE'
        HIDPP_QUIRK_CLASS_BLUETOOTH_LE },
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:75:44: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS BIT(33)
                                               ^~~
   drivers/hid/hid-logitech-hidpp.c:87:7: note: in expansion of macro 'HIDPP_QUIRK_WIRELESS_DEVICE_STATUS'
          HIDPP_QUIRK_WIRELESS_DEVICE_STATUS)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-logitech-hidpp.c:3826:5: note: in expansion of macro 'HIDPP_QUIRK_CLASS_BLUETOOTH_LE'
        HIDPP_QUIRK_CLASS_BLUETOOTH_LE },
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:74:43: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_MISSING_SHORT_REPORTS BIT(32)
                                              ^~~
   drivers/hid/hid-logitech-hidpp.c:86:41: note: in expansion of macro 'HIDPP_QUIRK_MISSING_SHORT_REPORTS'
    #define HIDPP_QUIRK_CLASS_BLUETOOTH_LE (HIDPP_QUIRK_MISSING_SHORT_REPORTS | \
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-logitech-hidpp.c:3829:5: note: in expansion of macro 'HIDPP_QUIRK_CLASS_BLUETOOTH_LE'
        HIDPP_QUIRK_CLASS_BLUETOOTH_LE },
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/bits.h:8:26: warning: left shift count >= width of type [-Wshift-count-overflow]
    #define BIT(nr)   (UL(1) << (nr))
                             ^
   drivers/hid/hid-logitech-hidpp.c:75:44: note: in expansion of macro 'BIT'
    #define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS BIT(33)
                                               ^~~
   drivers/hid/hid-logitech-hidpp.c:87:7: note: in expansion of macro 'HIDPP_QUIRK_WIRELESS_DEVICE_STATUS'
          HIDPP_QUIRK_WIRELESS_DEVICE_STATUS)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-logitech-hidpp.c:3829:5: note: in expansion of macro 'HIDPP_QUIRK_CLASS_BLUETOOTH_LE'
        HIDPP_QUIRK_CLASS_BLUETOOTH_LE },
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/HIDPP_QUIRK_WIRELESS_DEVICE_STATUS +412 drivers/hid/hid-logitech-hidpp.c

   408	
   409	static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp,
   410							 struct hidpp_report *report)
   411	{
 > 412		return ((hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) &&
   413			(report->fap.feature_index == hidpp->wireless_feature_index)) ||
   414		      (((report->report_id == REPORT_ID_HIDPP_SHORT) ||
   415			(hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) &&
   416			(report->rap.sub_id == 0x41));
   417	}
   418	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62065 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-14  3:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11 17:47 [PATCH v5 2/2] HID: logitech: Support WirelessDeviceStatus connect events Mazin Rezk
2019-10-14  3:46 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).