linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pedro Vanzella <pedro@pedrovanzella.com>
To: linux-input@vger.kernel.org
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] HID: hid-logitech-hidpp: subscribe to battery voltage change events
Date: Wed, 5 Jun 2019 12:40:56 -0400	[thread overview]
Message-ID: <20190605164056.ofueguibhjknm5wm@Fenrir> (raw)
In-Reply-To: <20190604232827.26008-2-pedro@pedrovanzella.com>

[-- Attachment #1: Type: text/plain, Size: 2308 bytes --]

Sorry for littering the list, but please ignore this patch set. I'll
have one that uses a quirk to detect the right devices in a little
while.

On 06/04, Pedro Vanzella wrote:
> Same as with the other ways of reporting battery status,
> fetch the battery voltage on raw hidpp events.
> 
> Signed-off-by: Pedro Vanzella <pedro@pedrovanzella.com>
> ---
>  drivers/hid/hid-logitech-hidpp.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index e68ea44b0d24..1eee206a0aed 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -1313,6 +1313,35 @@ static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp)
>  	return 0;
>  }
>  
> +static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp,
> +					 u8 *data, int size)
> +{
> +	struct hidpp_report *report = (struct hidpp_report *)data;
> +	int status, voltage;
> +	bool changed;
> +
> +	if (report->fap.feature_index != hidpp->battery.voltage_feature_index ||
> +	    report->fap.funcindex_clientid !=
> +		    EVENT_BATTERY_LEVEL_STATUS_BROADCAST)
> +		return 0;
> +
> +	status = hidpp20_battery_map_status_voltage(report->fap.params,
> +						    &voltage);
> +
> +	hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING;
> +
> +	changed = voltage != hidpp->battery.voltage ||
> +		  status != hidpp->battery.status;
> +
> +	if (changed) {
> +		hidpp->battery.voltage = voltage;
> +		hidpp->battery.status = status;
> +		if (hidpp->battery.ps)
> +			power_supply_changed(hidpp->battery.ps);
> +	}
> +	return 0;
> +}
> +
>  static enum power_supply_property hidpp_battery_props[] = {
>  	POWER_SUPPLY_PROP_ONLINE,
>  	POWER_SUPPLY_PROP_STATUS,
> @@ -3181,6 +3210,9 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
>  		ret = hidpp_solar_battery_event(hidpp, data, size);
>  		if (ret != 0)
>  			return ret;
> +		ret = hidpp20_battery_voltage_event(hidpp, data, size);
> +		if (ret != 0)
> +			return ret;
>  	}
>  
>  	if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) {
> -- 
> 2.21.0
> 

-- 
Pedro Vanzella
pedrovanzella.com
#include <paranoia.h>
Don't Panic

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2019-06-05 16:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 23:28 [PATCH 1/2] HID: hid-logitech-hidpp: Report battery voltage Pedro Vanzella
2019-06-04 23:28 ` [PATCH 2/2] HID: hid-logitech-hidpp: subscribe to battery voltage change events Pedro Vanzella
2019-06-05 16:40   ` Pedro Vanzella [this message]

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=20190605164056.ofueguibhjknm5wm@Fenrir \
    --to=pedro@pedrovanzella.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).