From: Bastien Nocera <hadess@hadess.net>
To: Peter Hutterer <peter.hutterer@who-t.net>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Nestor Lopez Casado <nlopezcasad@logitech.com>
Subject: Re: [PATCH 1/2] HID: logitech-hidpp: add battery support for HID++ 2.0 devices
Date: Fri, 08 Jul 2016 19:38:03 +0200 [thread overview]
Message-ID: <1467999483.2277.19.camel@hadess.net> (raw)
In-Reply-To: <1467988545.2317.4.camel@hadess.net>
On Fri, 2016-07-08 at 16:35 +0200, Bastien Nocera wrote:
> On Wed, 2016-06-29 at 19:28 +1000, Peter Hutterer wrote:
> > +static int hidpp_battery_get_property(struct power_supply *psy,
> > + enum power_supply_property
> > psp,
> > + union power_supply_propval
> > *val)
> > +{
> > + struct hidpp_device *hidpp = power_supply_get_drvdata(psy);
> > + int ret = 0;
> > +
> > + switch(psp) {
> > + case POWER_SUPPLY_PROP_STATUS:
> > + val->intval = hidpp->battery.status;
> > + break;
> > + case POWER_SUPPLY_PROP_CAPACITY:
> > + val->intval = hidpp->battery.level;
> > + break;
> > + default:
>
> You forgot to handle POWER_SUPPLY_PROP_SCOPE. This means that UPower
> thinks it's supplying power to the computer to which it is connected.
>
> Should be set to "POWER_SUPPLY_SCOPE_DEVICE". This should fix it.
I've also noticed that my keyboard appears 4 times:
$ cat /sys/class/power_supply/*/device/input/input*/name
Logitech K750
Logitech K750
Logitech Rechargeable Touchpad T650
Logitech K750
Logitech K750
By the way, instead of giving fake values when starting up, you should
use the ONLINE property instead. That way, when the property changes to
1, UPower can start taking the capacity value into account. In the
meanwhile, it would be ignored.
Finally, things like the serial number and model name and manufacturer
should be replicated in the power_supply, so that UPower can use them
too.
Fixing UPower to not do its user-space poking when a device appears
would be quite complicated. First, the unifier device will show up,
then as a child, the power_supply subsystem device, so we cannot just
probe when devices appear, as it would be in the wrong order for us.
Would it be possible to add a sysfs file that's there in those newer
versions of the kernel with this patch included? That way, I'd change
the lines in:
http://cgit.freedesktop.org/upower/tree/rules/95-upower-csr.rules
From:
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", DRIVER=="logitech-
hidpp-device", ENV{UPOWER_BATTERY_TYPE}="unifying"
to:
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", DRIVER=="logitech-
hidpp-device", TEST!="builtin_power_supply",
ENV{UPOWER_BATTERY_TYPE}="unifying"
For example.
Sorry about not being able to test this before it was merged for
inclusion.
Cheers
next prev parent reply other threads:[~2016-07-08 17:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 9:28 Peter Hutterer
2016-06-29 9:28 ` [PATCH 2/2] HID: logitech-hidpp: remove HIDPP_QUIRK_CONNECT_EVENTS Peter Hutterer
2016-07-07 9:34 ` [PATCH 1/2] HID: logitech-hidpp: add battery support for HID++ 2.0 devices Jiri Kosina
2016-07-07 23:21 ` Bastien Nocera
2016-07-08 4:34 ` Peter Hutterer
2016-07-08 14:35 ` Bastien Nocera
2016-07-08 17:38 ` Bastien Nocera [this message]
2016-07-08 18:24 ` Jiri Kosina
2016-07-11 11:18 ` Benjamin Tissoires
2016-07-11 11:33 ` Jiri Kosina
2016-07-11 11:03 ` Benjamin Tissoires
2016-07-11 10:54 ` Benjamin Tissoires
2016-07-13 5:18 ` Peter Hutterer
2017-01-26 15:02 ` Bastien Nocera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467999483.2277.19.camel@hadess.net \
--to=hadess@hadess.net \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nlopezcasad@logitech.com \
--cc=peter.hutterer@who-t.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome