OSDN Git Service

HID: i2c-hid: Support being a panel follower
authorDouglas Anderson <dianders@chromium.org>
Thu, 27 Jul 2023 17:16:36 +0000 (10:16 -0700)
committerDouglas Anderson <dianders@chromium.org>
Tue, 1 Aug 2023 14:41:26 +0000 (07:41 -0700)
commit96a37bfd232ae912648c73cd2dc29c13f1c7776a
treed56e0a989030902c6945f515ce6cb8cba0d8696c
parent5f8838e9405d74522f075e20864cce1cda604bfe
HID: i2c-hid: Support being a panel follower

As talked about in the patch ("drm/panel: Add a way for other devices
to follow panel state"), we really want to keep the power states of a
touchscreen and the panel it's attached to in sync with each other. In
that spirit, add support to i2c-hid to be a panel follower. This will
let the i2c-hid driver get informed when the panel is powered on and
off. From there we can match the i2c-hid device's power state to that
of the panel.

NOTE: this patch specifically _doesn't_ use pm_runtime to keep track
of / manage the power state of the i2c-hid device, even though my
first instinct said that would be the way to go. Specific problems
with using pm_runtime():
* The initial power up couldn't happen in a runtime resume function
  since it create sub-devices and, apparently, that's not good to do
  in your resume function.
* Managing our power state with pm_runtime meant fighting to make the
  right thing happen at system suspend to prevent the system from
  trying to resume us only to suspend us again. While this might be
  able to be solved, it added complexity.
Overall the code without pm_runtime() ended up being smaller and
easier to understand.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Benjamin Tissoires <bentiss@kernel.org>
Acked-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230727101636.v4.9.Ib1a98309c455cd7e26b931c69993d4fba33bbe15@changeid
drivers/hid/i2c-hid/Kconfig
drivers/hid/i2c-hid/i2c-hid-core.c