linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: "José Expósito" <jose.exposito89@gmail.com>,
	"Mia Kanashi" <chad@redpilled.dev>
Cc: jikos@kernel.org, benjamin.tissoires@redhat.com,
	spbnick@gmail.com, pobrn@protonmail.com,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andreas Grosse <andig.mail@t-online.de>
Subject: Re: [PATCH v2] HID: uclogic: Add support for XP-PEN Deco LW
Date: Sun, 30 Oct 2022 12:34:09 +0100	[thread overview]
Message-ID: <c6ec738617a839a692bc3eb1317c1eb9cae29fe0.camel@hadess.net> (raw)
In-Reply-To: <20221029145511.GA7941@elementary>

On Sat, 2022-10-29 at 16:55 +0200, José Expósito wrote:
> Hi!
> 
> On Sat, Oct 29, 2022 at 04:55:21PM +0300, Mia Kanashi wrote:
> > > > [1] Actually it should be set to discharging until this gets
> > > > merged:
> > > >   
> > > > https://lore.kernel.org/linux-input/20221028181849.23157-1-jose.exposito89@gmail.com/T/
> > > 
> > > But i also currently applied this ^ patch, i will try testing
> > > without it and then report.
> > 
> > Tested without it, same issue.
> > So yeah it seems that hid-input driver can set supply status to
> > discharging before setting a battery capacity? 
> 
> Very good catch. I managed to reproduce it using the USB dongle. I
> didn't notice it before because I was running upower after connecting
> the device, which isn't fast enough. However, using watch as you
> suggested makes the issue pretty noticeable.
> 
> The problem is that the battery is fetched when the USB dongle is
> connected. However, the tablet might not be paired at that point.
> 
> To explain it with the actual code:
> 
> 
>   if (dev->battery_status != HID_BATTERY_REPORTED &&
>       !dev->battery_avoid_query) {
>         value = hidinput_query_battery_capacity(dev);
>                 ^ Here the battery is fetched, but because the tabled
>                   is not paired and this function returns garbage
>         if (value < 0)
>                 return value;
> 
>         dev->battery_capacity = value;
>         dev->battery_status = HID_BATTERY_QUERIED;
>                             ^ Now the battery is set as queried
>   }
> 
>   if (dev->battery_status == HID_BATTERY_UNKNOWN)
>         val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
>   else
>         val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
>                     ^ And therefore the battery is reported
> 
> 
> Thankfully, there is already a flag (battery_avoid_query) used to
> solve
> the same issue on stylus. The battery percentage is unknown until the
> stylus is in proximity.
> 
> So I guess I could use the same flag to avoid this problem.
> 
> I'll add a fix in a second revision of this patch.

UPower will also respect the POWER_SUPPLY_PROP_PRESENT property, if
that's useful.

      parent reply	other threads:[~2022-10-30 11:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28  8:23 [PATCH v2] HID: uclogic: Add support for XP-PEN Deco LW José Expósito
2022-10-29  0:28 ` Mia Kanashi
2022-10-29  7:58   ` José Expósito
2022-10-29 12:13     ` Mia Kanashi
2022-10-29 13:55       ` Mia Kanashi
2022-10-29 14:55         ` José Expósito
2022-10-29 16:04           ` Mia Kanashi
2022-10-30 11:34           ` Bastien Nocera [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=c6ec738617a839a692bc3eb1317c1eb9cae29fe0.camel@hadess.net \
    --to=hadess@hadess.net \
    --cc=andig.mail@t-online.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=chad@redpilled.dev \
    --cc=jikos@kernel.org \
    --cc=jose.exposito89@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pobrn@protonmail.com \
    --cc=spbnick@gmail.com \
    /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).