Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 19 Apr 2019 17:28:27 +0000 (10:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 19 Apr 2019 17:28:27 +0000 (10:28 -0700)
Pull input updates from Dmitry Torokhov:

 - several new key mappings for HID

 - a host of new ACPI IDs used to identify Elan touchpads in Lenovo
   laptops

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: snvs_pwrkey - initialize necessary driver data before enabling IRQ
  HID: input: add mapping for "Toggle Display" key
  HID: input: add mapping for "Full Screen" key
  HID: input: add mapping for keyboard Brightness Up/Down/Toggle keys
  HID: input: add mapping for Expose/Overview key
  HID: input: fix mapping of aspect ratio key
  [media] doc-rst: switch to new names for Full Screen/Aspect keys
  Input: document meanings of KEY_SCREEN and KEY_ZOOM
  Input: elan_i2c - add hardware ID for multiple Lenovo laptops

1  2 
Documentation/media/uapi/rc/rc-tables.rst
drivers/hid/hid-input.c
include/uapi/linux/input-event-codes.h

index f460031d85313821ac91d940b915d26994d1ed00,57797e56f45e0786389d8f080820e395b7a62b10..177ac44fa0fac33363d34f840c663d4699039a79
@@@ -1,11 -1,4 +1,11 @@@
 -.. -*- coding: utf-8; mode: rst -*-
 +.. Permission is granted to copy, distribute and/or modify this
 +.. document under the terms of the GNU Free Documentation License,
 +.. Version 1.1 or any later version published by the Free Software
 +.. Foundation, with no Invariant Sections, no Front-Cover Texts
 +.. and no Back-Cover Texts. A copy of the license is included at
 +.. Documentation/media/uapi/fdl-appendix.rst.
 +..
 +.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
  
  .. _Remote_controllers_tables:
  
@@@ -385,7 -378,7 +385,7 @@@ the remote via /dev/input/event devices
  
         -  ``KEY_CHANNELDOWN``
  
 -       -  Decrease channel sequencially
 +       -  Decrease channel sequentially
  
         -  CHANNEL - / CHANNEL DOWN / DOWN
  
  
         -  ``KEY_CHANNELUP``
  
 -       -  Increase channel sequencially
 +       -  Increase channel sequentially
  
         -  CHANNEL + / CHANNEL UP / UP
  
  
      -  .. row 78
  
-        -  ``KEY_SCREEN``
+        -  ``KEY_ASPECT_RATIO``
  
         -  Select screen aspect ratio
  
  
      -  .. row 79
  
-        -  ``KEY_ZOOM``
+        -  ``KEY_FULL_SCREEN``
  
         -  Put device into zoom/full screen mode
  
diff --combined drivers/hid/hid-input.c
index 1fce0076e7dc470e94cf561bf8c55b78cd92c6f2,da76358cde06fb4f8d01cc76e91ee5627af62db6..b607286a0bc82f360a133b5dce204a8f2441ff5c
@@@ -328,9 -328,6 +328,9 @@@ static const struct hid_device_id hid_b
        { HID_USB_DEVICE(USB_VENDOR_ID_SYMBOL,
                USB_DEVICE_ID_SYMBOL_SCANNER_3),
          HID_BATTERY_QUIRK_IGNORE },
 +      { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
 +              USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD),
 +        HID_BATTERY_QUIRK_IGNORE },
        {}
  };
  
@@@ -680,6 -677,14 +680,14 @@@ static void hidinput_configure_usage(st
                        break;
                }
  
+               if ((usage->hid & 0xf0) == 0xb0) {      /* SC - Display */
+                       switch (usage->hid & 0xf) {
+                       case 0x05: map_key_clear(KEY_SWITCHVIDEOMODE); break;
+                       default: goto ignore;
+                       }
+                       break;
+               }
                /*
                 * Some lazy vendors declare 255 usages for System Control,
                 * leading to the creation of ABS_X|Y axis and too many others.
                                map_abs_clear(usage->hid & 0xf);
                        break;
  
 -              case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL:
 +              case HID_GD_WHEEL:
 +                      if (field->flags & HID_MAIN_ITEM_RELATIVE) {
 +                              set_bit(REL_WHEEL, input->relbit);
 +                              map_rel(REL_WHEEL_HI_RES);
 +                      } else {
 +                              map_abs(usage->hid & 0xf);
 +                      }
 +                      break;
 +              case HID_GD_SLIDER: case HID_GD_DIAL:
                        if (field->flags & HID_MAIN_ITEM_RELATIVE)
                                map_rel(usage->hid & 0xf);
                        else
                case 0x06a: map_key_clear(KEY_GREEN);           break;
                case 0x06b: map_key_clear(KEY_BLUE);            break;
                case 0x06c: map_key_clear(KEY_YELLOW);          break;
-               case 0x06d: map_key_clear(KEY_ZOOM);            break;
+               case 0x06d: map_key_clear(KEY_ASPECT_RATIO);    break;
  
                case 0x06f: map_key_clear(KEY_BRIGHTNESSUP);            break;
                case 0x070: map_key_clear(KEY_BRIGHTNESSDOWN);          break;
                case 0x074: map_key_clear(KEY_BRIGHTNESS_MAX);          break;
                case 0x075: map_key_clear(KEY_BRIGHTNESS_AUTO);         break;
  
+               case 0x079: map_key_clear(KEY_KBDILLUMUP);      break;
+               case 0x07a: map_key_clear(KEY_KBDILLUMDOWN);    break;
+               case 0x07c: map_key_clear(KEY_KBDILLUMTOGGLE);  break;
                case 0x082: map_key_clear(KEY_VIDEO_NEXT);      break;
                case 0x083: map_key_clear(KEY_LAST);            break;
                case 0x084: map_key_clear(KEY_ENTER);           break;
                case 0x1b8: map_key_clear(KEY_VIDEO);           break;
                case 0x1bc: map_key_clear(KEY_MESSENGER);       break;
                case 0x1bd: map_key_clear(KEY_INFO);            break;
 +              case 0x1cb: map_key_clear(KEY_ASSISTANT);       break;
                case 0x201: map_key_clear(KEY_NEW);             break;
                case 0x202: map_key_clear(KEY_OPEN);            break;
                case 0x203: map_key_clear(KEY_CLOSE);           break;
                case 0x22d: map_key_clear(KEY_ZOOMIN);          break;
                case 0x22e: map_key_clear(KEY_ZOOMOUT);         break;
                case 0x22f: map_key_clear(KEY_ZOOMRESET);       break;
+               case 0x232: map_key_clear(KEY_FULL_SCREEN);     break;
                case 0x233: map_key_clear(KEY_SCROLLUP);        break;
                case 0x234: map_key_clear(KEY_SCROLLDOWN);      break;
 -              case 0x238: map_rel(REL_HWHEEL);                break;
 +              case 0x238: /* AC Pan */
 +                      set_bit(REL_HWHEEL, input->relbit);
 +                      map_rel(REL_HWHEEL_HI_RES);
 +                      break;
                case 0x23d: map_key_clear(KEY_EDIT);            break;
                case 0x25f: map_key_clear(KEY_CANCEL);          break;
                case 0x269: map_key_clear(KEY_INSERT);          break;
                case 0x2cb: map_key_clear(KEY_KBDINPUTASSIST_ACCEPT);   break;
                case 0x2cc: map_key_clear(KEY_KBDINPUTASSIST_CANCEL);   break;
  
+               case 0x29f: map_key_clear(KEY_SCALE);           break;
                default: map_key_clear(KEY_UNKNOWN);
                }
                break;
@@@ -1215,38 -1215,6 +1230,38 @@@ ignore
  
  }
  
 +static void hidinput_handle_scroll(struct hid_usage *usage,
 +                                 struct input_dev *input,
 +                                 __s32 value)
 +{
 +      int code;
 +      int hi_res, lo_res;
 +
 +      if (value == 0)
 +              return;
 +
 +      if (usage->code == REL_WHEEL_HI_RES)
 +              code = REL_WHEEL;
 +      else
 +              code = REL_HWHEEL;
 +
 +      /*
 +       * Windows reports one wheel click as value 120. Where a high-res
 +       * scroll wheel is present, a fraction of 120 is reported instead.
 +       * Our REL_WHEEL_HI_RES axis does the same because all HW must
 +       * adhere to the 120 expectation.
 +       */
 +      hi_res = value * 120/usage->resolution_multiplier;
 +
 +      usage->wheel_accumulated += hi_res;
 +      lo_res = usage->wheel_accumulated/120;
 +      if (lo_res)
 +              usage->wheel_accumulated -= lo_res * 120;
 +
 +      input_event(input, EV_REL, code, lo_res);
 +      input_event(input, EV_REL, usage->code, hi_res);
 +}
 +
  void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
  {
        struct input_dev *input;
        if ((usage->type == EV_KEY) && (usage->code == 0)) /* Key 0 is "unassigned", not KEY_UNKNOWN */
                return;
  
 +      if ((usage->type == EV_REL) && (usage->code == REL_WHEEL_HI_RES ||
 +                                      usage->code == REL_HWHEEL_HI_RES)) {
 +              hidinput_handle_scroll(usage, input, value);
 +              return;
 +      }
 +
        if ((usage->type == EV_ABS) && (field->flags & HID_MAIN_ITEM_RELATIVE) &&
                        (usage->code == ABS_VOLUME)) {
                int count = abs(value);
@@@ -1542,58 -1504,6 +1557,58 @@@ static void hidinput_close(struct input
        hid_hw_close(hid);
  }
  
 +static void hidinput_change_resolution_multipliers(struct hid_device *hid)
 +{
 +      struct hid_report_enum *rep_enum;
 +      struct hid_report *rep;
 +      struct hid_usage *usage;
 +      int i, j;
 +
 +      rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
 +      list_for_each_entry(rep, &rep_enum->report_list, list) {
 +              bool update_needed = false;
 +
 +              if (rep->maxfield == 0)
 +                      continue;
 +
 +              /*
 +               * If we have more than one feature within this report we
 +               * need to fill in the bits from the others before we can
 +               * overwrite the ones for the Resolution Multiplier.
 +               */
 +              if (rep->maxfield > 1) {
 +                      hid_hw_request(hid, rep, HID_REQ_GET_REPORT);
 +                      hid_hw_wait(hid);
 +              }
 +
 +              for (i = 0; i < rep->maxfield; i++) {
 +                      __s32 logical_max = rep->field[i]->logical_maximum;
 +
 +                      /* There is no good reason for a Resolution
 +                       * Multiplier to have a count other than 1.
 +                       * Ignore that case.
 +                       */
 +                      if (rep->field[i]->report_count != 1)
 +                              continue;
 +
 +                      for (j = 0; j < rep->field[i]->maxusage; j++) {
 +                              usage = &rep->field[i]->usage[j];
 +
 +                              if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER)
 +                                      continue;
 +
 +                              *rep->field[i]->value = logical_max;
 +                              update_needed = true;
 +                      }
 +              }
 +              if (update_needed)
 +                      hid_hw_request(hid, rep, HID_REQ_SET_REPORT);
 +      }
 +
 +      /* refresh our structs */
 +      hid_setup_resolution_multiplier(hid);
 +}
 +
  static void report_features(struct hid_device *hid)
  {
        struct hid_driver *drv = hid->driver;
@@@ -1887,8 -1797,6 +1902,8 @@@ int hidinput_connect(struct hid_device 
                }
        }
  
 +      hidinput_change_resolution_multipliers(hid);
 +
        list_for_each_entry_safe(hidinput, next, &hid->inputs, list) {
                if (drv->input_configured &&
                    drv->input_configured(hid, hidinput))
@@@ -1947,3 -1855,4 +1962,3 @@@ void hidinput_disconnect(struct hid_dev
        cancel_work_sync(&hid->led_work);
  }
  EXPORT_SYMBOL_GPL(hidinput_disconnect);
 -
index 7f14d4a66c28c1c13d1388c6dacfcff30711edab,bc5054e51bef837167f9e24a6adf561a8196d6f8..64cee116928ebd92d97acec08c273e02c89958ab
  #define KEY_TITLE             0x171
  #define KEY_SUBTITLE          0x172
  #define KEY_ANGLE             0x173
- #define KEY_ZOOM              0x174
+ #define KEY_FULL_SCREEN               0x174   /* AC View Toggle */
+ #define KEY_ZOOM              KEY_FULL_SCREEN
  #define KEY_MODE              0x175
  #define KEY_KEYBOARD          0x176
- #define KEY_SCREEN            0x177
+ #define KEY_ASPECT_RATIO      0x177   /* HUTRR37: Aspect */
+ #define KEY_SCREEN            KEY_ASPECT_RATIO
  #define KEY_PC                        0x178   /* Media Select Computer */
  #define KEY_TV                        0x179   /* Media Select TV */
  #define KEY_TV2                       0x17a   /* Media Select Cable */
   * the situation described above.
   */
  #define REL_RESERVED          0x0a
 +#define REL_WHEEL_HI_RES      0x0b
 +#define REL_HWHEEL_HI_RES     0x0c
  #define REL_MAX                       0x0f
  #define REL_CNT                       (REL_MAX+1)