]> Git Repo - linux.git/commitdiff
Merge branch 'for-6.3/hid-core' into for-linus
authorBenjamin Tissoires <[email protected]>
Wed, 22 Feb 2023 09:27:57 +0000 (10:27 +0100)
committerBenjamin Tissoires <[email protected]>
Wed, 22 Feb 2023 09:27:57 +0000 (10:27 +0100)
- constify hid_ll_driver (Thomas Weißschuh)
- map standard Battery System Charging to upower (José Expósito)
- couple of assorted fixes and new handling of HID usages (Jingyuan
  Liang & Ronald Tschalär)

1  2 
drivers/hid/Kconfig
drivers/hid/hid-core.c
drivers/hid/hid-input.c

diff --combined drivers/hid/Kconfig
index e2a5d30c88956077273ce8022482fd88b1fe8470,1aa7b6614c2074abb9d05dc6cebe325c2512789b..d253b3ff2e0c77f513fafab81404831299132b89
@@@ -897,7 -897,7 +897,7 @@@ config HID_PLAYSTATIO
        select CRC32
        select POWER_SUPPLY
        help
 -        Provides support for Sony PS5 controllers including support for
 +        Provides support for Sony PS4/PS5 controllers including support for
          its special functionalities e.g. touchpad, lights and motion
          sensors.
  
@@@ -1264,6 -1264,7 +1264,7 @@@ config HID_MCP222
  config HID_KUNIT_TEST
        tristate "KUnit tests for HID" if !KUNIT_ALL_TESTS
        depends on KUNIT=y
+       depends on HID_BATTERY_STRENGTH
        depends on HID_UCLOGIC
        default KUNIT_ALL_TESTS
        help
diff --combined drivers/hid/hid-core.c
index 5c72aef3d3dd5fb6fed8e5323ad0271e907ea8b3,7e7ae20e29ffb48de31538872f9cbb080c22c9ae..53e4d5831caf87aa97b476d91961bbe7c7a697b2
  
  #define DRIVER_DESC "HID core driver"
  
- int hid_debug = 0;
- module_param_named(debug, hid_debug, int, 0600);
- MODULE_PARM_DESC(debug, "toggle HID debugging messages");
- EXPORT_SYMBOL_GPL(hid_debug);
  static int hid_ignore_special_drivers = 0;
  module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600);
  MODULE_PARM_DESC(ignore_special_drivers, "Ignore any special drivers and handle all devices by generic driver");
@@@ -804,7 -799,8 +799,8 @@@ static void hid_scan_collection(struct 
        int i;
  
        if (((parser->global.usage_page << 16) == HID_UP_SENSOR) &&
-           type == HID_COLLECTION_PHYSICAL)
+           (type == HID_COLLECTION_PHYSICAL ||
+            type == HID_COLLECTION_APPLICATION))
                hid->group = HID_GROUP_SENSOR_HUB;
  
        if (hid->vendor == USB_VENDOR_ID_MICROSOFT &&
@@@ -993,8 -989,8 +989,8 @@@ struct hid_report *hid_validate_values(
                 * Validating on id 0 means we should examine the first
                 * report in the list.
                 */
 -              report = list_entry(
 -                              hid->report_enum[type].report_list.next,
 +              report = list_first_entry_or_null(
 +                              &hid->report_enum[type].report_list,
                                struct hid_report, list);
        } else {
                report = hid->report_enum[type].report_id_hash[id];
@@@ -1202,7 -1198,6 +1198,7 @@@ int hid_open_report(struct hid_device *
        __u8 *end;
        __u8 *next;
        int ret;
 +      int i;
        static int (*dispatch_type[])(struct hid_parser *parser,
                                      struct hid_item *item) = {
                hid_parser_main,
                goto err;
        }
        device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
 +      for (i = 0; i < HID_DEFAULT_NUM_COLLECTIONS; i++)
 +              device->collection[i].parent_idx = -1;
  
        ret = -EINVAL;
        while ((next = fetch_item(start, end, &item)) != NULL) {
@@@ -2912,10 -2905,6 +2908,6 @@@ static int __init hid_init(void
  {
        int ret;
  
-       if (hid_debug)
-               pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
-                       "debugfs is now used for inspecting the device (report descriptor, reports)\n");
        ret = bus_register(&hid_bus_type);
        if (ret) {
                pr_err("can't register hid bus\n");
diff --combined drivers/hid/hid-input.c
index 77c8c49852b5c252d85b7f37a1ae6f357b086d16,ac9f6c4d042487b13213ef49da2d63223be10b70..743e518b983678381d53e605a1f3f938b0385c17
@@@ -370,8 -370,6 +370,8 @@@ static const struct hid_device_id hid_b
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
                USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD),
          HID_BATTERY_QUIRK_IGNORE },
 +      { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_TP420IA_TOUCHSCREEN),
 +        HID_BATTERY_QUIRK_IGNORE },
        { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN),
          HID_BATTERY_QUIRK_IGNORE },
        { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN),
          HID_BATTERY_QUIRK_IGNORE },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100),
          HID_BATTERY_QUIRK_IGNORE },
 +      { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_EU0009NV),
 +        HID_BATTERY_QUIRK_IGNORE },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_15),
          HID_BATTERY_QUIRK_IGNORE },
 +      { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_13_AW0020NG),
 +        HID_BATTERY_QUIRK_IGNORE },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN),
          HID_BATTERY_QUIRK_IGNORE },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN),
@@@ -486,7 -480,7 +486,7 @@@ static int hidinput_get_battery_propert
                if (dev->battery_status == HID_BATTERY_UNKNOWN)
                        val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
                else
-                       val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+                       val->intval = dev->battery_charge_status;
                break;
  
        case POWER_SUPPLY_PROP_SCOPE:
@@@ -554,6 -548,7 +554,7 @@@ static int hidinput_setup_battery(struc
        dev->battery_max = max;
        dev->battery_report_type = report_type;
        dev->battery_report_id = field->report->id;
+       dev->battery_charge_status = POWER_SUPPLY_STATUS_DISCHARGING;
  
        /*
         * Stylus is normally not connected to the device and thus we
@@@ -620,6 -615,20 +621,20 @@@ static void hidinput_update_battery(str
                power_supply_changed(dev->battery);
        }
  }
+ static bool hidinput_set_battery_charge_status(struct hid_device *dev,
+                                              unsigned int usage, int value)
+ {
+       switch (usage) {
+       case HID_BAT_CHARGING:
+               dev->battery_charge_status = value ?
+                                            POWER_SUPPLY_STATUS_CHARGING :
+                                            POWER_SUPPLY_STATUS_DISCHARGING;
+               return true;
+       }
+       return false;
+ }
  #else  /* !CONFIG_HID_BATTERY_STRENGTH */
  static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
                                  struct hid_field *field, bool is_percentage)
@@@ -634,6 -643,12 +649,12 @@@ static void hidinput_cleanup_battery(st
  static void hidinput_update_battery(struct hid_device *dev, int value)
  {
  }
+ static bool hidinput_set_battery_charge_status(struct hid_device *dev,
+                                              unsigned int usage, int value)
+ {
+       return false;
+ }
  #endif        /* CONFIG_HID_BATTERY_STRENGTH */
  
  static bool hidinput_field_in_collection(struct hid_device *device, struct hid_field *field,
@@@ -793,6 -808,14 +814,14 @@@ static void hidinput_configure_usage(st
                        break;
                }
  
+               if ((usage->hid & 0xf0) == 0xa0) {      /* SystemControl */
+                       switch (usage->hid & 0xf) {
+                       case 0x9: map_key_clear(KEY_MICMUTE); break;
+                       default: goto ignore;
+                       }
+                       break;
+               }
                if ((usage->hid & 0xf0) == 0xb0) {      /* SC - Display */
                        switch (usage->hid & 0xf) {
                        case 0x05: map_key_clear(KEY_SWITCHVIDEOMODE); break;
                        hidinput_setup_battery(device, HID_INPUT_REPORT, field, true);
                        usage->type = EV_PWR;
                        return;
+               case HID_BAT_CHARGING:
+                       usage->type = EV_PWR;
+                       return;
                }
                goto unknown;
  
@@@ -1465,7 -1491,11 +1497,11 @@@ void hidinput_hid_event(struct hid_devi
                return;
  
        if (usage->type == EV_PWR) {
-               hidinput_update_battery(hid, value);
+               bool handled = hidinput_set_battery_charge_status(hid, usage->hid, value);
+               if (!handled)
+                       hidinput_update_battery(hid, value);
                return;
        }
  
@@@ -2321,3 -2351,7 +2357,7 @@@ void hidinput_disconnect(struct hid_dev
        cancel_work_sync(&hid->led_work);
  }
  EXPORT_SYMBOL_GPL(hidinput_disconnect);
+ #ifdef CONFIG_HID_KUNIT_TEST
+ #include "hid-input-test.c"
+ #endif
This page took 0.078926 seconds and 4 git commands to generate.