Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp635898rwj; Sat, 29 Oct 2022 08:27:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fFSieg+0VzOngGvGyfUjTrnjRffO+qea9N9YlGXekfJfFEiCYnSbij+gy7DECJx1ELAgV X-Received: by 2002:a17:907:1b12:b0:72f:9b44:f9e with SMTP id mp18-20020a1709071b1200b0072f9b440f9emr4177320ejc.653.1667057230194; Sat, 29 Oct 2022 08:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667057230; cv=none; d=google.com; s=arc-20160816; b=sLKZm8H+XzT26PrJqN6Lbx+JsJDyQdwBv3IKt1q3DYYOOfwfjnZNgBIdCE3Q8g7cMH Olpxf7GZmyIj4BW4LM2juA+j8Y+Q308zwW7ezJ3z95KHACeb+HWqaZXnKlYvpI9rAvof vSKHoSqVsFgete8kqhF3+24rAM0g8UDyROQMQ3QZC9qoSnhRRi1+tdlUnj17Myt89MzU SdLUWxh9+hWEVbFKztotqp+1ltRd25/Nx4mEnIaOS4ZB1xI6FYgqajQGQiNYUvmoLL7Y mcdBGN179/M/uFGI94EHiMcWgnxvzxoa/JpMrDqOprfkchNvaiAxV1RlSnfEnmzdF0DH QChQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Mz5TY/LtkLWNd5ySUogpHG94P5HHBB7Mk5dPpz+NcdA=; b=U2AOabbQq71EFm7vgNKd8wVu2Gxl/pdNS1QsG2bg9Gibzuu1A05ch/NL+BsflMFuNP LV9iPsSwmDHS5Q40zdndxLqYbAuFG5U5Y4OwleSHbhENhGEOfF4Ou6oFF4O/vN9UhMtc oaNln/Dwoxvsxo/LqoxKbQWcC1hNt/t7NehZOv7farVpQOQiKNz7o2ReiYvRl/N2EMiU pvG4MO+5YmM/uPdQjsDc7SyMexAbSGl7dqX2Hoxq3U+RTPVm3SKCVKFKWgph2HEP0hKc SsJT/Fyvmt/nNcMmNIthHw94RJ/c/LB0mmUNMYPSn9wBl+mnFc+LgNKakAKxmgC0SgOm KEcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IWk7W49j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a1709063e5200b0079330b37fb6si1279117eji.880.2022.10.29.08.26.45; Sat, 29 Oct 2022 08:27:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IWk7W49j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbiJ2Oza (ORCPT + 99 others); Sat, 29 Oct 2022 10:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbiJ2OzR (ORCPT ); Sat, 29 Oct 2022 10:55:17 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A50EB20F7E; Sat, 29 Oct 2022 07:55:15 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id k4so596245wri.9; Sat, 29 Oct 2022 07:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Mz5TY/LtkLWNd5ySUogpHG94P5HHBB7Mk5dPpz+NcdA=; b=IWk7W49jd16h4QCOdKnC2dqhR81Zwa7m7wflpedDLqja8GppdvSwxvODl0MneU14dn 93D92I5s08ScbNXyXU9ZXA2HKjlHu4q2vZQ4AcAIX4P2MOEEWjelDNYuHlPfV3OlzKuw 2fYy9Q48rngw015jWwdTplLkvmsWKu65WF36F74he+vD47Mc+ruD5dWiVuUszIXpVoKC UaFOWdU7F34sbPW9syMRddHiDF5VXoZ2RobfmfReufnRYyRc2wiAoYv2IB36k6Ksfmtm ySWAK/v3NaN6FaVqYxLMsCW/dYuVKiRcyE+k51xsWVQg/9MJ3nyJZVmh4y7MiAtXSm/X GYgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mz5TY/LtkLWNd5ySUogpHG94P5HHBB7Mk5dPpz+NcdA=; b=NYL2wjslOaWof6mH2/eoWOcxf+yDgo/JsIPFCIdGcXuRXdPa4vqB6QT9VDS0CW3An/ c0e3AlnJDVS4a80EqgkjwWlDukirDejDQVxjRSqEoK2BMgX8G6nc2abptoUrHP1X6DeI OEdeL3z9lTcPhxIV+BPiE4b2xkzS4Kc6lx2sklbsTgrRsqVaRStClCZZIuh4zmVWVhje gYT5mq0WzKxx2+0lNnuVcZ4BBm/Z+1+vathtoCLs/I24p4m+JfXIfmNLQD6LpX7xkmSl gHUlr2DwvK9KnVFNGhZvGOkbbLjWT9gAIizNPJW4HXx+FwUJQVYiDcRyGiezvDAr7+EO olqA== X-Gm-Message-State: ACrzQf3jrA3lbofN1lkXYl/68XmTchyfd4bAnX0HTZQHb9FVrhQ3QjVx F3gXmU0tRR/gHrdGcQnActY= X-Received: by 2002:a5d:61c9:0:b0:236:781a:8d7e with SMTP id q9-20020a5d61c9000000b00236781a8d7emr2572305wrv.576.1667055314058; Sat, 29 Oct 2022 07:55:14 -0700 (PDT) Received: from elementary ([94.73.35.109]) by smtp.gmail.com with ESMTPSA id t12-20020adff60c000000b002366ded5864sm1644157wrp.116.2022.10.29.07.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 07:55:13 -0700 (PDT) Date: Sat, 29 Oct 2022 16:55:11 +0200 From: =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= To: Mia Kanashi 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 Subject: Re: [PATCH v2] HID: uclogic: Add support for XP-PEN Deco LW Message-ID: <20221029145511.GA7941@elementary> References: <20221028082348.22386-1-jose.exposito89@gmail.com> <20221029075832.GA8790@elementary> <21CA0A00-1B9F-4E97-B942-A3B7CAA2B52E@redpilled.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks!!