Bug 217062
Summary: | Unnecessary battery is exported for Wacom panel | ||
---|---|---|---|
Product: | Drivers | Reporter: | Mario Limonciello (AMD) (mario.limonciello) |
Component: | Input Devices | Assignee: | drivers_input-devices |
Status: | RESOLVED CODE_FIX | ||
Severity: | normal | CC: | bugzilla, killertofu, pingc |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | 6.2 | Subsystem: | |
Regression: | No | Bisected commit-id: |
Description
Mario Limonciello (AMD)
2023-02-20 15:38:08 UTC
> Presumably this is for an optional stylus? Yes, almost certainly. This appears to be a sensor for a (battery-powered) AES pen. > [...] they said that the wacom driver overloaded the present attribute to not > mean "battery present" but instead "device present". The driver /does/ use the "present" attribute to mean "battery present", but that attribute alone has no way to communicate an "unknown" value. We can only know the state of a stylus battery if it is within proximity of the sensor (a couple cm at most). When the stylus is outside of this range, /anything/ could be happening with the battery (maybe its charging? maybe its not? maybe the user doesn't even /have/ a stylus, or just lent it to someone else for the day) and we have no way to know. To communicate this lack of knowledge to userspace we set POWER_SUPPLY_STATUS=Unknown whenever the stylus is outside of proximity. When a pen is brought close enough for us to read its battery state we'll update the properties accordingly and set POWER_SUPPLY_STATUS=Discharging. Once the pen leaves proximity, we change POWER_SUPPLY_STATUS=Unknown again. In my opinion, userspace should be ignoring (or maybe just greying out) the device if POWER_SUPPLY_STATUS=Unknown. But maybe we're misunderstanding what that flag is intended to mean? > As the device isn't actually present, the proposal was to not register the > battery until the device is present. I don't really like this as a solution, though I do understand where its coming from. 'The "power supply" is in the stylus so why should there be a power_supply device registered when there's no stylus?' Makes sense. What doesn't make as much sense is what to do about the power_supply device after the pen leaves proximity. Do we just leave it in place until the next reboot? Do we set a timer in the kernel to remove it after an arbitrary amount of time? Do we remove it every time the pen leaves proximity? Is there a lighter-weight alternative to creating/removing power_supply devices to let userspace know that the device being powered isn't available right now (e.g. POWER_SUPPLY_STATUS=Unknown or similar)? Thanks for the feedback! > within proximity of the sensor (a couple cm at most) Well so in practice you'll only be able to get useful data (at least from GNOME) if you open up the GNOME control center battery panel and then move it close to the screen. I'd say 99% of the time this has no sense in being shown in GNOME. > In my opinion, userspace should be ignoring (or maybe just greying out) the > device if POWER_SUPPLY_STATUS=Unknown. But maybe we're misunderstanding what > that flag is intended to mean? I personally think this sounds reasonable. > What doesn't make as much sense is what to do about the power_supply device > after the pen leaves proximity. Do we just leave it in place until the next > reboot? Do we set a timer in the kernel to remove it after an arbitrary > amount of time? Do we remove it every time the pen leaves proximity? Is there > a lighter-weight alternative to creating/removing power_supply devices to let > userspace know that the device being powered isn't available right now (e.g. > POWER_SUPPLY_STATUS=Unknown or similar)? Given it's only available when the device is super close to the screen I tend to agree it seems expensive to create/remove devices constantly. @Bastien what do you think? >> within proximity of the sensor (a couple cm at most) > > Well so in practice you'll only be able to get useful data (at least from > GNOME) if you open up the GNOME control center battery panel and then move it > close to the screen. I'd say 99% of the time this has no sense in being > shown in GNOME. This might actually be a good argument for a larger change to how the driver reports the battery status from AES pens. I can imagine users wanting to see the battery level for the pen they have "recently" used, even if it isn't in prox at that exact moment. Having the driver report non-Unknown (but potentially stale) data for a short time (few minutes?) would achieve this. It would also probably somewhat-improve the situation for users who have complained that GNOME pops up a fresh low-battery warning every single time their pen enters proximity... (I'm not sure if that's still an issue or if GNOME did something about it...) If you make such a change, presumably you can also put off reporting the existence of a battery until the first time a pen connects, right? That would completely avoid the GNOME issue as I reproduced it. (In reply to Mario Limonciello (AMD) from comment #2) > Thanks for the feedback! > > > within proximity of the sensor (a couple cm at most) > > Well so in practice you'll only be able to get useful data (at least from > GNOME) if you open up the GNOME control center battery panel and then move > it close to the screen. I'd say 99% of the time this has no sense in being > shown in GNOME. > > > In my opinion, userspace should be ignoring (or maybe just greying out) the > > device if POWER_SUPPLY_STATUS=Unknown. But maybe we're misunderstanding > what > > that flag is intended to mean? > > I personally think this sounds reasonable. > > > What doesn't make as much sense is what to do about the power_supply device > > after the pen leaves proximity. Do we just leave it in place until the next > > reboot? Do we set a timer in the kernel to remove it after an arbitrary > > amount of time? Do we remove it every time the pen leaves proximity? Is > there > > a lighter-weight alternative to creating/removing power_supply devices to > let > > userspace know that the device being powered isn't available right now > (e.g. > > POWER_SUPPLY_STATUS=Unknown or similar)? > > Given it's only available when the device is super close to the screen I > tend to agree it seems expensive to create/remove devices constantly. > > > @Bastien what do you think? I don't really mind how you encode it, but it needs to be documented in the power_supply ABI docs before it's used in that way. POWER_SUPPLY_STATUS=Unknown isn't good enough though, as that might be the status of a device with, say, AA batteries where the battery voltage takes a while to settle. A quick grep POWER_SUPPLY_STATUS_UNKNOWN confirms that it would be a bad idea to use that to mean "device isn't around". As I've mentioned before, you're probably looking at a new attribute that will need to be documented before it's used, so everyone is on the same page. What about the combination of POWER_SUPPLY_STATUS=Unknown and POWER_SUPPLY_PRESENT=0 both? Could that cover this case well enough for now or do you still think a new property is needed? I don't think it's good enough. It probably happens in some corner cases that don't match this one, it's undocumented and really, it's not related to the power_supply/battery itself. Thinking about it, it would be better for the parent device (the input device) to have a sysfs attribute for the proximity that user-space could consume without having to listen to input events themselves. Do you want to send a mail to linux-input to discuss it? > Do you want to send a mail to linux-input to discuss it? https://lore.kernel.org/linux-input/MN0PR12MB6101F4408960BDB9CF63DD53E2AB9@MN0PR12MB6101.namprd12.prod.outlook.com/T/#u Wacom's patches are in linux-next, I'm going to close this issue. https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/commit/?h=for-next&id=7fc68653fc2e1a3457bb886e10164119ac48734f https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/commit/?h=for-next&id=bea407a427baa019758f29f4d31b26f008bb8cc6 |