Hi Luiz,
This change accompanies a change in the kernel to allow marking devices
as wakeable so they can wake the system from suspend. Currently, only
HID devices support this and will be configured to allow this setting to
be changed via the WakeAllowed property.
Accompanying kernel change: https://patchwork.kernel.org/patch/11609999/
In order to set this flag, Bluez must call Set Device Flags with the
Remote Wakeup bit set. This change was tested with the accompanying
kernel changes on v5.4 with both manual tests and automated tests.
Here's the tests that I ran manually:
- Pair new HID device and confirm it has Wake Allowed to True
(default). Verify device can be woken from suspend with device.
- Restart bluetoothd, confirm Device Flags Changed event after Add
Device has no Remote Wakeup flag and Set Device Flags is called
afterwards to restore it. Verify wake from suspend still works.
- Disable Wake allowed via dbus and confirm wake from suspend no
longer works.
- Restart bluetoothd and confirm Wake Allowed is still false. Verify
wake from suspend does not work.
Thanks
Abhishek
Changes in v7:
* Fix more build issues reported by bluez.test.bot
Changes in v6:
* Fix up some build issues reported by bluez.test.bot
* Save pending property id and emit success only after set flags returns
* Ignore multiple calls to set_wake_allowed to the same value
* Emit property error busy if same value is already sent to mgmt
* Fix up build issues reported by bluez.test.bot
Changes in v5:
- Use device_flags mgmt op
* Decode device flags
* Refactor to use set_wake_flags and respond to device flags changed
* Add wake_override so we can keep track of user/profile configuration
vs what is currently active
* Only call device_set_wake_support
Changes in v4:
* Renamed wake_capable to wake_allowed
* Removed set_wake_capable mgmt op and updated add_device to accept
flags to set whether a device is wakeable
* Refactored adapter_whitelist_add and adapter_auto_connect_add to call
adapter_add_device
* Renamed WakeCapable to WakeAllowed
* Renamed WakeCapable to WakeAllowed
* Renamed device_set_profile_wake_support to just
device_set_wake_support
Changes in v3:
* Added profile_wake_support and made wake_capable dependent on it
* Added documentation for WakeCapable
* Mark HID device to support wake from suspend
Changes in v2:
* Added dbus api "WakeCapable" to set value
* Update device_set_wake_capable to be called by
adapter_set_wake_capable_complete so we can emit property changed
* Newly added to show whether device is wake capable
* Removed automatically setting wake capable for HID devices
Abhishek Pandit-Subedi (6):
mgmt: Add mgmt op and events for device flags
monitor: Decode device flags mgmt ops and event
device: Support marking a device with wake allowed
client: Display wake allowed property with info
doc/device-api: Add WakeAllowed
input: Make HID devices support wake
client/main.c | 1 +
doc/device-api.txt | 5 +
lib/mgmt.h | 33 +++++++
monitor/packet.c | 70 ++++++++++++++
profiles/input/device.c | 1 +
profiles/input/hog.c | 1 +
src/adapter.c | 93 ++++++++++++++++++
src/adapter.h | 3 +-
src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++
src/device.h | 10 ++
10 files changed, 426 insertions(+), 1 deletion(-)
--
2.27.0.212.ge8ba1cc988-goog
HID devices can wake the host from a suspended state. Mark the profiles
to support wake when they are accepted. If the device hasn't already
been configured with a Wake Allowed configuration, it will default to
yes when the profile is accepted.
---
Changes in v7: None
Changes in v6: None
Changes in v5:
* Only call device_set_wake_support
Changes in v4:
* Renamed device_set_profile_wake_support to just
device_set_wake_support
Changes in v3:
* Mark HID device to support wake from suspend
Changes in v2: None
profiles/input/device.c | 1 +
profiles/input/hog.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/profiles/input/device.c b/profiles/input/device.c
index d3724ed54..2dc2ecab2 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -1409,6 +1409,7 @@ int input_device_register(struct btd_service *service)
}
btd_service_set_user_data(service, idev);
+ device_set_wake_support(device, true);
return 0;
}
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 9335b7e8b..130f696a9 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -166,6 +166,7 @@ static int hog_probe(struct btd_service *service)
return -EINVAL;
btd_service_set_user_data(service, dev);
+ device_set_wake_support(device, true);
return 0;
}
--
2.27.0.212.ge8ba1cc988-goog
Hi Abhishek,
On Mon, Jul 6, 2020 at 1:25 PM Abhishek Pandit-Subedi
<[email protected]> wrote:
>
>
> Hi Luiz,
>
> This change accompanies a change in the kernel to allow marking devices
> as wakeable so they can wake the system from suspend. Currently, only
> HID devices support this and will be configured to allow this setting to
> be changed via the WakeAllowed property.
>
> Accompanying kernel change: https://patchwork.kernel.org/patch/11609999/
>
> In order to set this flag, Bluez must call Set Device Flags with the
> Remote Wakeup bit set. This change was tested with the accompanying
> kernel changes on v5.4 with both manual tests and automated tests.
>
> Here's the tests that I ran manually:
> - Pair new HID device and confirm it has Wake Allowed to True
> (default). Verify device can be woken from suspend with device.
> - Restart bluetoothd, confirm Device Flags Changed event after Add
> Device has no Remote Wakeup flag and Set Device Flags is called
> afterwards to restore it. Verify wake from suspend still works.
> - Disable Wake allowed via dbus and confirm wake from suspend no
> longer works.
> - Restart bluetoothd and confirm Wake Allowed is still false. Verify
> wake from suspend does not work.
>
> Thanks
> Abhishek
>
> Changes in v7:
> * Fix more build issues reported by bluez.test.bot
>
> Changes in v6:
> * Fix up some build issues reported by bluez.test.bot
> * Save pending property id and emit success only after set flags returns
> * Ignore multiple calls to set_wake_allowed to the same value
> * Emit property error busy if same value is already sent to mgmt
> * Fix up build issues reported by bluez.test.bot
>
> Changes in v5:
> - Use device_flags mgmt op
> * Decode device flags
> * Refactor to use set_wake_flags and respond to device flags changed
> * Add wake_override so we can keep track of user/profile configuration
> vs what is currently active
> * Only call device_set_wake_support
>
> Changes in v4:
> * Renamed wake_capable to wake_allowed
> * Removed set_wake_capable mgmt op and updated add_device to accept
> flags to set whether a device is wakeable
> * Refactored adapter_whitelist_add and adapter_auto_connect_add to call
> adapter_add_device
> * Renamed WakeCapable to WakeAllowed
> * Renamed WakeCapable to WakeAllowed
> * Renamed device_set_profile_wake_support to just
> device_set_wake_support
>
> Changes in v3:
> * Added profile_wake_support and made wake_capable dependent on it
> * Added documentation for WakeCapable
> * Mark HID device to support wake from suspend
>
> Changes in v2:
> * Added dbus api "WakeCapable" to set value
> * Update device_set_wake_capable to be called by
> adapter_set_wake_capable_complete so we can emit property changed
> * Newly added to show whether device is wake capable
> * Removed automatically setting wake capable for HID devices
>
> Abhishek Pandit-Subedi (6):
> mgmt: Add mgmt op and events for device flags
> monitor: Decode device flags mgmt ops and event
> device: Support marking a device with wake allowed
> client: Display wake allowed property with info
> doc/device-api: Add WakeAllowed
> input: Make HID devices support wake
>
> client/main.c | 1 +
> doc/device-api.txt | 5 +
> lib/mgmt.h | 33 +++++++
> monitor/packet.c | 70 ++++++++++++++
> profiles/input/device.c | 1 +
> profiles/input/hog.c | 1 +
> src/adapter.c | 93 ++++++++++++++++++
> src/adapter.h | 3 +-
> src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++
> src/device.h | 10 ++
> 10 files changed, 426 insertions(+), 1 deletion(-)
>
> --
> 2.27.0.212.ge8ba1cc988-goog
Applied, thanks.
--
Luiz Augusto von Dentz
Thanks Luiz.
On Tue, Jul 7, 2020 at 10:50 AM Luiz Augusto von Dentz
<[email protected]> wrote:
>
> Hi Abhishek,
>
> On Mon, Jul 6, 2020 at 1:25 PM Abhishek Pandit-Subedi
> <[email protected]> wrote:
> >
> >
> > Hi Luiz,
> >
> > This change accompanies a change in the kernel to allow marking devices
> > as wakeable so they can wake the system from suspend. Currently, only
> > HID devices support this and will be configured to allow this setting to
> > be changed via the WakeAllowed property.
> >
> > Accompanying kernel change: https://patchwork.kernel.org/patch/11609999/
> >
> > In order to set this flag, Bluez must call Set Device Flags with the
> > Remote Wakeup bit set. This change was tested with the accompanying
> > kernel changes on v5.4 with both manual tests and automated tests.
> >
> > Here's the tests that I ran manually:
> > - Pair new HID device and confirm it has Wake Allowed to True
> > (default). Verify device can be woken from suspend with device.
> > - Restart bluetoothd, confirm Device Flags Changed event after Add
> > Device has no Remote Wakeup flag and Set Device Flags is called
> > afterwards to restore it. Verify wake from suspend still works.
> > - Disable Wake allowed via dbus and confirm wake from suspend no
> > longer works.
> > - Restart bluetoothd and confirm Wake Allowed is still false. Verify
> > wake from suspend does not work.
> >
> > Thanks
> > Abhishek
> >
> > Changes in v7:
> > * Fix more build issues reported by bluez.test.bot
> >
> > Changes in v6:
> > * Fix up some build issues reported by bluez.test.bot
> > * Save pending property id and emit success only after set flags returns
> > * Ignore multiple calls to set_wake_allowed to the same value
> > * Emit property error busy if same value is already sent to mgmt
> > * Fix up build issues reported by bluez.test.bot
> >
> > Changes in v5:
> > - Use device_flags mgmt op
> > * Decode device flags
> > * Refactor to use set_wake_flags and respond to device flags changed
> > * Add wake_override so we can keep track of user/profile configuration
> > vs what is currently active
> > * Only call device_set_wake_support
> >
> > Changes in v4:
> > * Renamed wake_capable to wake_allowed
> > * Removed set_wake_capable mgmt op and updated add_device to accept
> > flags to set whether a device is wakeable
> > * Refactored adapter_whitelist_add and adapter_auto_connect_add to call
> > adapter_add_device
> > * Renamed WakeCapable to WakeAllowed
> > * Renamed WakeCapable to WakeAllowed
> > * Renamed device_set_profile_wake_support to just
> > device_set_wake_support
> >
> > Changes in v3:
> > * Added profile_wake_support and made wake_capable dependent on it
> > * Added documentation for WakeCapable
> > * Mark HID device to support wake from suspend
> >
> > Changes in v2:
> > * Added dbus api "WakeCapable" to set value
> > * Update device_set_wake_capable to be called by
> > adapter_set_wake_capable_complete so we can emit property changed
> > * Newly added to show whether device is wake capable
> > * Removed automatically setting wake capable for HID devices
> >
> > Abhishek Pandit-Subedi (6):
> > mgmt: Add mgmt op and events for device flags
> > monitor: Decode device flags mgmt ops and event
> > device: Support marking a device with wake allowed
> > client: Display wake allowed property with info
> > doc/device-api: Add WakeAllowed
> > input: Make HID devices support wake
> >
> > client/main.c | 1 +
> > doc/device-api.txt | 5 +
> > lib/mgmt.h | 33 +++++++
> > monitor/packet.c | 70 ++++++++++++++
> > profiles/input/device.c | 1 +
> > profiles/input/hog.c | 1 +
> > src/adapter.c | 93 ++++++++++++++++++
> > src/adapter.h | 3 +-
> > src/device.c | 210 ++++++++++++++++++++++++++++++++++++++++
> > src/device.h | 10 ++
> > 10 files changed, 426 insertions(+), 1 deletion(-)
> >
> > --
> > 2.27.0.212.ge8ba1cc988-goog
>
> Applied, thanks.
>
> --
> Luiz Augusto von Dentz