1. 30 10月, 2013 1 次提交
    • D
      HID: wiimote: add pro-controller analog stick calibration · 08072dde
      David Herrmann 提交于
      The analog sticks of the pro-controller might report slightly off values.
      To guarantee a uniform setup, we now calibrate analog-stick values during
      pro-controller setup.
      
      Unfortunately, the pro-controller fails during normal EEPROM reads and I
      couldn't figure out whether there are any calibration values stored on the
      device. Therefore, we now use the first values reported by the device (iff
      they are not _way_ off, which would indicate movement) to initialize the
      calibration values. To allow users to change this calibration data, we
      provide a pro_calib sysfs attribute.
      
      We also change the "flat" values so user-space correctly smoothes our
      data. It makes slightly off zero-positions less visible while still
      guaranteeing highly precise movement reports. Note that the pro controller
      reports zero-positions in a quite huge range (at least: -100 to +100).
      Reported-by: NRafael Brune <mail@rbrune.de>
      Tested-by: NRafael Brune <mail@rbrune.de>
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      08072dde
  2. 07 10月, 2013 1 次提交
    • D
      HID: wiimote: fix FF deadlock · f50f9aab
      David Herrmann 提交于
      The input core has an internal spinlock that is acquired during event
      injection via input_event() and friends but also held during FF callbacks.
      That means, there is no way to share a lock between event-injection and FF
      handling. Unfortunately, this is what is required for wiimote state
      tracking and what we do with state.lock and input->lock.
      
      This deadlock can be triggered when using continuous data reporting and FF
      on a wiimote device at the same time. I takes me at least 30m of
      stress-testing to trigger it but users reported considerably shorter
      times (http://bpaste.net/show/132504/) when using some gaming-console
      emulators.
      
      The real problem is that we have two copies of internal state, one in the
      wiimote objects and the other in the input device. As the input-lock is
      not supposed to be accessed from outside of input-core, we have no other
      chance than offloading FF handling into a worker. This actually works
      pretty nice and also allows to implictly merge fast rumble changes into a
      single request.
      
      Due to the 3-layered workers (rumble+queue+l2cap) this might reduce FF
      responsiveness. Initial tests were fine so lets fix the race first and if
      it turns out to be too slow we can always handle FF out-of-band and skip
      the queue-worker.
      
      Cc: <stable@vger.kernel.org> # 3.11+
      Reported-by: Thomas Schneider
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      f50f9aab
  3. 08 9月, 2013 1 次提交
  4. 04 9月, 2013 2 次提交
  5. 27 6月, 2013 1 次提交
    • D
      HID: wiimote: support Nintendo Wii U Pro Controller · b8e0fe31
      David Herrmann 提交于
      The Wii U Pro Controller is a new Nintendo remote device that looks very
      similar to the XBox controller. It has nearly the same features and uses
      the same protocol as the Wii Remote.
      
      We add a new wiimote extension device so the Pro Controller is properly
      detected and supported.
      
      The device reports MP support, which is odd and I couldn't get it working,
      yet. Hence, we disable MP registers for now. Further investigation is
      needed to see what extra capabilities are provided.
      
      There are some other unknown bits in the extension reports that I couldn't
      figure out what they do. You can use hidraw to access these if you're
      interested.
      
      We might want to hook up the "charging" and "USB" bits to the battery
      device so user-space can query whether it is currently charged via USB.
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      b8e0fe31
  6. 03 6月, 2013 18 次提交
    • D
      HID: wiimote: add MP quirks · 9f329741
      David Herrmann 提交于
      Devices which have built-in motion plus ports don't need MP detection
      logic. The new WIIMOD_BUILTIN_MP modules sets the WIIPROTO_FLAG_BUILTIN_MP
      flag which disables polling for MP.
      
      Some other devices erroneously report that they support motion-plus. For
      these devices and all devices without extension ports, we load
      WIIMOD_NO_MP which sets WIIPROTO_FLAG_NO_MP. This effectively disables all
      MP detection logic.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      9f329741
    • D
      HID: wiimote: remove old static extension support · 45ec9fff
      David Herrmann 提交于
      We now have dynamic hotplug support so the old static extensions are no
      longer needed nor used. Remove it along CONFIG_HID_WIIMOTE_EXT.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      45ec9fff
    • D
      HID: wiimote: lock DRM mode during debugfs overwrite · d76f89e1
      David Herrmann 提交于
      If we write a DRM mode via debugfs, we shouldn't allow normal operations
      to overwrite this DRM mode. This is important if we want to debug
      3rd-party devices and we want to see what data is sent on each mode.
      
      If we write NULL/0 as DRM, the lock is removed again so the best matching
      DRM is chosen by wiimote core.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      d76f89e1
    • D
      HID: wiimote: add Motion Plus extension module · 34472d37
      David Herrmann 提交于
      Add parsers for motion plus data so we can hotplug motion plus extensions
      and make use of them. This is mostly the same as the old static motion
      plus parser.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      34472d37
    • D
      HID: wiimote: add Classic Controller extension · 9d6f9ecb
      David Herrmann 提交于
      Add a new extension module for the classic controller so we get hotplug
      support for this device. It is mostly the same as the old static classic
      controller parser.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      9d6f9ecb
    • D
      HID: wiimote: add Nunchuk support · b6ee67b3
      David Herrmann 提交于
      This moves the nunchuk parser over to an extension module. This allows to
      make use of hotplugged Nunchuks instead of the old static parser.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      b6ee67b3
    • D
      HID: wiimote: add Balance Board support · f1d4bed4
      David Herrmann 提交于
      This adds Nintendo Wii Balance Board support to the new HOTPLUG capable
      wiimote core. It is mostly copied from the old extension.
      
      This also adds Balance Board device detection. Whenever we find a device
      that supports the balance-board extension, we assume that it is a real
      balance board and disable unsupported hardward like accelerometer, IR,
      rumble and more.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      f1d4bed4
    • D
      HID: wiimote: add extension hotplug support · 4148b6bf
      David Herrmann 提交于
      The Wii Remote has several extension ports. The first port (EXT) provides
      hotplug events whenever an extension is plugged. The second port (MP)
      does not provide hotplug events by default. Instead, we have to map MP
      into EXT to get events for it.
      
      This patch introduces hotplug support for extensions. It is fairly
      complicated to get this right because the Wii Remote sends a lot of
      noise-hotplug events while activating extension ports. We need to filter
      the events and only handle the events that are real hotplug events.
      
      Mapping MP into EXT is easy. But if we want both, MP _and_ EXT at the same
      time, we need to map MP into EXT and enable a passthrough-mode. This will
      then send real EXT events through the mapped MP interleaved with real MP
      events. But once MP is mapped, we no longer have access to the real EXT
      registers so we need to perform setup _before_ mapping MP. Furthermore, we
      no longer can read EXT IDs so we cannot verify if EXT is still the same
      extension that we expect it to be.
      We deal with this by unmapping MP whenever we got into a situation where
      EXT might have changed. We then re-read EXT and MP and remap everything.
      
      The real Wii Console takes a fairly easy approach: It simply reconnects to
      the device on hotplug events that it didn't expect. So if a program wants
      MP events, but MP is disconnected, it fails and reconnects so it can wait
      for MP hotplug events again.
      This simplifies hotplugging a lot because we just react on PLUG events and
      ignore UNPLUG events.
      The more sophisticated Wii applications avoid reconnection (well, they
      still reconnect during many weird events, but at least not during UNPLUG)
      but they start polling the device. This allows them to disable the device,
      poll for the extension ports to settle and then initialize them again.
      Unfortunately, this approach fails whenever an extension is replugged
      while it is initialized. We would loose UNPLUG events and polling the
      device later will give unreliable results because the extension port might
      be in some weird state, even though it's actually unplugged.
      
      Our approach is a real HOTPLUG approch. We keep track of the EXT and
      mapped MP hotplug events whenever they occur. We then re-evaluate the
      device state and initialize any possible new extension or deinitialize any
      gone extension. Only during initialization, we set an extension port
      ACTIVE. However, during an unplug event we mark them as INACTIVE. This
      guarantess that a fast UNPLUG -> PLUG event sequence doesn't keep them
      marked as PLUGGED+ACTIVE but only PLUGGED.
      To deal with annoying noise-hotplug events during extension mapping, we
      simply rescan the device before performing any mapping. This allows us to
      ignore all the noise events as long as the device is in the correct state.
      
      Long story short: EXT and MP registers are sparsely known and we need to
      jump through hoops to get reliable HOTPLUG working. But while Nintendo
      needs *FOUR* Bluetooth reconnections for the shortest imaginable
      boot->menu->game->menu->shutdown sequence, we now need *ZERO*.
      
      As always, 3rd party devices tend to break whenever we behave differently
      than the original Wii. So there are also devices which _expect_ a
      disconnect after UNPLUG. Obviously, these devices won't benefit from this
      patch. But all official devices were tested extensively and work great
      during any hotplug sequence. Yay!
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      4148b6bf
    • D
      HID: wiimote: convert IR to module · 3b5f03c4
      David Herrmann 提交于
      IR is the last piece that still is handled natively. This patch converts
      it into a sub-device module like all other sub-devices. It mainly moves
      code and doesn't change semantics.
      
      We also implicitly sync IR data on ir_to_input3 now so the explicit
      input_sync() calls are no longer needed.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      3b5f03c4
    • D
      HID: wiimote: convert ACCEL to module · 0ea16757
      David Herrmann 提交于
      Accelerometer data is very similar to KEYS handling. Therefore, convert
      all ACCEL related handling into a sub-device module similar to KEYS.
      
      This doesn't change any semantics but only moves code over to
      wiimote-modules.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      0ea16757
    • D
      HID: wiimote: convert LEDS to modules · 6c5ae018
      David Herrmann 提交于
      Each of the 4 LEDs may be supported individually by devices. Therefore,
      we need one module for each device. To avoid code-duplication, we simply
      pass the LED ID as "arg" argument to the module loading code.
      
      This just moves the code over to wiimote-module. The semantics stay the
      same as before.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      6c5ae018
    • D
      HID: wiimote: convert BATTERY to module · dcf39231
      David Herrmann 提交于
      This introduces a new sub-device module for the BATTERY handlers. It
      moves the whole power_supply battery handling over to wiimote-modules.
      
      This doesn't change any semantics or ABI but only converts the battery
      handling into a sub-device module.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      dcf39231
    • D
      HID: wiimote: convert KEYS and RUMBLE to modules · 20cef813
      David Herrmann 提交于
      This introduces the first sub-device modules by converting the KEYS and
      RUMBLE sub-devices into wiimote modules. Both must be converted at once
      because they depend on the built-in shared input device.
      
      This mostly moves code from wiimote-core to wiimote-modules and doesn't
      change any semantics or ABI.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      20cef813
    • D
      HID: wiimote: add sub-device module infrastructure · 27f06942
      David Herrmann 提交于
      To avoid loading all sub-device drivers for every Wii Remote, even though
      the required hardware might not be available, we introduce a module layer.
      
      The module layer specifies which sub-devices are available on each
      device-type. After device detection, we only load the modules for the
      detected device. If module loading fails, we unload everything and mark
      the device as WIIMOTE_DEV_UNKNOWN. As long as a device is marked as
      "unknown", no sub-devices will be used and the device is considered
      unsupported.
      
      All the different sub-devices, including KEYS, RUMBLE, BATTERY, LEDS,
      ACCELEROMETER, IR and more will be ported in follow-up patches to the new
      module layer.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      27f06942
    • D
      HID: wiimote: wake up if output queue failed · d758b1f0
      David Herrmann 提交于
      Our output queue is asynchronous but synchronous reports may wait for a
      response to their request. Therefore, wake them up unconditionally if an
      output report couldn't be sent. But keep the report ID intact so we don't
      incorrectly assume our request succeeded.
      
      Note that the underlying connection is required to be reliable and does
      retransmission itself. So it is safe to assume that if the transmission
      fails, the device is in inconsistent state. Hence, we abort every request
      if any output report fails. No need to verify which report failed.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      d758b1f0
    • D
      HID: wiimote: add device detection · c57ff761
      David Herrmann 提交于
      Nintendo produced many different devices that are internally based on the
      Wii Remote protocol but provide different peripherals. To support these
      devices, we need to schedule a device detection during initialization.
      
      Device detection includes requesting a status report, reading extension
      information and then evaluating which device we may be dealing with.
      
      We currently detect gen1 and gen2 Wii Remote devices. All other devices
      are marked as generic devices. More detections will be added later.
      
      In followup patches we will be using these device IDs to control which
      peripherals to initialize. For instance if a device is known to have no IR
      camera, there is no need to provide the IR input device nor trying to
      access IR registers. In fact, there are 3rd party devices that break if we
      try things like this (hurray!).
      
      The init_worker will be scheduled whenever we get hotplug events. This
      isn't implemented, yet and will be added later. However, we need to make
      sure that this worker can be called multiple times.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      c57ff761
    • D
      HID: wiimote: move queue handling into separate struct · 13938538
      David Herrmann 提交于
      The output queue is independent of the other wiimote modules and can run
      on its own. Therefore, move its members into a separate struct so we don't
      run into name collisions with other modules.
      
      This is only a syntactic change that renames all queue members to queue.*.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      13938538
    • D
      HID: wiimote: extend driver description · 92eda7e4
      David Herrmann 提交于
      The hid-wiimote driver supports more than the Wii Remote. Nintendo
      produced many devices based on the Wii Remote, which have extension
      devices built-in. It is not clear to many users, that these devices have
      anything in common with the Wii Remote, so fix the driver description.
      
      This also updates the copyright information for the coming hotplugging
      rework.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      92eda7e4
  7. 23 11月, 2011 7 次提交