Linux Input/HID development
 help / color / mirror / Atom feed
* Re: [PATCH regression fix 0/2] Input: atkbd - Fix Dell XPS 13 line suspend/resume regression
From: Linux regression tracking (Thorsten Leemhuis) @ 2024-02-01 11:12 UTC (permalink / raw)
  To: Hans de Goede, Dmitry Torokhov
  Cc: Paul Menzel, stable, regressions, linux-input
In-Reply-To: <20240126160724.13278-1-hdegoede@redhat.com>

On 26.01.24 17:07, Hans de Goede wrote:
> Hi Dmitry,
> 
> There have been multiple reports that the keyboard on
> Dell XPS 13 9350 / 9360 / 9370 models has stopped working after
> a suspend/resume after the merging of commit 936e4d49ecbc ("Input:
> atkbd - skip ATKBD_CMD_GETID in translated mode").
> 
> See the 4 closes tags in the first patch for 4 reports of this.
> 
> I have been working with the first reporter on resolving this
> and testing on his Dell XPS 13 9360 confirms that these patches
> fix things.
> 
> Unfortunately the commit causing the issue has also been picked
> up by multiple stable kernel series now. Can you please send
> these fixes to Linus ASAP, so that they can also be backported
> to the stable series ASAP ?

Dmitry,  Hans, what's the status here? I wonder if there is still a
chance to get this into -rc3 so that Greg can fix the affected stable
trees as well next week or so.

Ciao, Thorsten

> Hans de Goede (2):
>   Input: atkbd - Skip ATKBD_CMD_SETLEDS when skipping ATKBD_CMD_GETID
>   Input: atkbd - Do not skip atkbd_deactivate() when skipping
>     ATKBD_CMD_GETID
> 
>  drivers/input/keyboard/atkbd.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 

^ permalink raw reply

* [dtor-input:for-linus] BUILD SUCCESS 2b9c3eb32a699acdd4784d6b93743271b4970899
From: kernel test robot @ 2024-02-01 11:08 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus
branch HEAD: 2b9c3eb32a699acdd4784d6b93743271b4970899  Input: bcm5974 - check endpoint type before starting traffic

elapsed time: 956m

configs tested: 163
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

tested configs:
alpha                             allnoconfig   gcc  
alpha                            allyesconfig   gcc  
alpha                               defconfig   gcc  
arc                              allmodconfig   gcc  
arc                               allnoconfig   gcc  
arc                              allyesconfig   gcc  
arc                                 defconfig   gcc  
arc                   randconfig-001-20240201   gcc  
arc                   randconfig-002-20240201   gcc  
arm                              allmodconfig   gcc  
arm                               allnoconfig   gcc  
arm                              allyesconfig   gcc  
arm                                 defconfig   clang
arm                   randconfig-001-20240201   gcc  
arm                   randconfig-002-20240201   clang
arm                   randconfig-002-20240201   gcc  
arm                   randconfig-003-20240201   gcc  
arm                   randconfig-004-20240201   clang
arm                   randconfig-004-20240201   gcc  
arm64                            allmodconfig   clang
arm64                             allnoconfig   gcc  
arm64                               defconfig   gcc  
arm64                 randconfig-001-20240201   gcc  
arm64                 randconfig-002-20240201   clang
arm64                 randconfig-002-20240201   gcc  
arm64                 randconfig-003-20240201   gcc  
arm64                 randconfig-004-20240201   gcc  
csky                             allmodconfig   gcc  
csky                              allnoconfig   gcc  
csky                             allyesconfig   gcc  
csky                                defconfig   gcc  
csky                  randconfig-001-20240201   gcc  
csky                  randconfig-002-20240201   gcc  
hexagon                          allmodconfig   clang
hexagon                           allnoconfig   clang
hexagon                          allyesconfig   clang
hexagon                             defconfig   clang
hexagon               randconfig-001-20240201   clang
hexagon               randconfig-002-20240201   clang
i386                             allmodconfig   clang
i386                              allnoconfig   clang
i386                             allyesconfig   clang
i386         buildonly-randconfig-001-20240201   gcc  
i386         buildonly-randconfig-002-20240201   gcc  
i386         buildonly-randconfig-003-20240201   gcc  
i386         buildonly-randconfig-004-20240201   gcc  
i386         buildonly-randconfig-005-20240201   gcc  
i386         buildonly-randconfig-006-20240201   gcc  
i386                                defconfig   gcc  
i386                  randconfig-001-20240201   gcc  
i386                  randconfig-002-20240201   gcc  
i386                  randconfig-003-20240201   gcc  
i386                  randconfig-004-20240201   gcc  
i386                  randconfig-005-20240201   gcc  
i386                  randconfig-006-20240201   gcc  
i386                  randconfig-011-20240201   clang
i386                  randconfig-012-20240201   clang
i386                  randconfig-013-20240201   clang
i386                  randconfig-014-20240201   clang
i386                  randconfig-015-20240201   clang
i386                  randconfig-016-20240201   clang
loongarch                        allmodconfig   gcc  
loongarch                         allnoconfig   gcc  
loongarch                           defconfig   gcc  
loongarch             randconfig-001-20240201   gcc  
loongarch             randconfig-002-20240201   gcc  
m68k                             allmodconfig   gcc  
m68k                              allnoconfig   gcc  
m68k                             allyesconfig   gcc  
m68k                                defconfig   gcc  
microblaze                       allmodconfig   gcc  
microblaze                        allnoconfig   gcc  
microblaze                       allyesconfig   gcc  
microblaze                          defconfig   gcc  
mips                              allnoconfig   clang
mips                             allyesconfig   gcc  
nios2                            allmodconfig   gcc  
nios2                             allnoconfig   gcc  
nios2                            allyesconfig   gcc  
nios2                               defconfig   gcc  
nios2                 randconfig-001-20240201   gcc  
nios2                 randconfig-002-20240201   gcc  
openrisc                          allnoconfig   gcc  
openrisc                         allyesconfig   gcc  
openrisc                            defconfig   gcc  
parisc                           allmodconfig   gcc  
parisc                            allnoconfig   gcc  
parisc                           allyesconfig   gcc  
parisc                              defconfig   gcc  
parisc                randconfig-001-20240201   gcc  
parisc                randconfig-002-20240201   gcc  
parisc64                            defconfig   gcc  
powerpc                          allmodconfig   clang
powerpc                           allnoconfig   gcc  
powerpc                          allyesconfig   clang
powerpc               randconfig-001-20240201   clang
powerpc               randconfig-002-20240201   clang
powerpc               randconfig-003-20240201   gcc  
powerpc64             randconfig-001-20240201   clang
powerpc64             randconfig-002-20240201   clang
powerpc64             randconfig-003-20240201   gcc  
riscv                            allmodconfig   gcc  
riscv                             allnoconfig   clang
riscv                            allyesconfig   gcc  
riscv                               defconfig   gcc  
riscv                 randconfig-001-20240201   gcc  
riscv                 randconfig-002-20240201   clang
riscv                          rv32_defconfig   clang
s390                             allmodconfig   gcc  
s390                              allnoconfig   gcc  
s390                             allyesconfig   gcc  
s390                                defconfig   gcc  
s390                  randconfig-001-20240201   gcc  
s390                  randconfig-002-20240201   clang
sh                               allmodconfig   gcc  
sh                                allnoconfig   gcc  
sh                               allyesconfig   gcc  
sh                                  defconfig   gcc  
sh                    randconfig-001-20240201   gcc  
sh                    randconfig-002-20240201   gcc  
sparc                            allmodconfig   gcc  
sparc                             allnoconfig   gcc  
sparc                               defconfig   gcc  
sparc64                          allmodconfig   gcc  
sparc64                          allyesconfig   gcc  
sparc64                             defconfig   gcc  
sparc64               randconfig-001-20240201   gcc  
sparc64               randconfig-002-20240201   gcc  
um                               allmodconfig   clang
um                                allnoconfig   clang
um                               allyesconfig   gcc  
um                                  defconfig   gcc  
um                             i386_defconfig   gcc  
um                    randconfig-001-20240201   gcc  
um                    randconfig-002-20240201   gcc  
um                           x86_64_defconfig   gcc  
x86_64                            allnoconfig   gcc  
x86_64                           allyesconfig   clang
x86_64       buildonly-randconfig-001-20240201   gcc  
x86_64       buildonly-randconfig-002-20240201   gcc  
x86_64       buildonly-randconfig-003-20240201   gcc  
x86_64       buildonly-randconfig-004-20240201   gcc  
x86_64       buildonly-randconfig-005-20240201   gcc  
x86_64       buildonly-randconfig-006-20240201   gcc  
x86_64                              defconfig   gcc  
x86_64                randconfig-001-20240201   clang
x86_64                randconfig-002-20240201   clang
x86_64                randconfig-003-20240201   clang
x86_64                randconfig-004-20240201   clang
x86_64                randconfig-005-20240201   clang
x86_64                randconfig-006-20240201   clang
x86_64                randconfig-011-20240201   gcc  
x86_64                randconfig-012-20240201   gcc  
x86_64                randconfig-013-20240201   gcc  
x86_64                randconfig-014-20240201   gcc  
x86_64                randconfig-015-20240201   gcc  
x86_64                randconfig-016-20240201   gcc  
x86_64                randconfig-071-20240201   gcc  
x86_64                randconfig-072-20240201   gcc  
x86_64                randconfig-073-20240201   gcc  
x86_64                randconfig-074-20240201   gcc  
x86_64                randconfig-075-20240201   gcc  
x86_64                randconfig-076-20240201   gcc  
x86_64                          rhel-8.3-rust   clang
xtensa                            allnoconfig   gcc  
xtensa                randconfig-001-20240201   gcc  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply

* Re: [PATCH v4 1/3] dt-bindings: HID: i2c-hid: Document reset-related properties
From: Johan Hovold @ 2024-02-01 10:05 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold, linux-arm-msm, linux-input, devicetree,
	linux-kernel, Konrad Dybcio, Krzysztof Kozlowski, Rob Herring
In-Reply-To: <20240131-x13s-touchscreen-v4-1-39c0f9925d3c@quicinc.com>

On Wed, Jan 31, 2024 at 07:07:26PM -0800, Bjorn Andersson wrote:
> Some I2C HID devices has a reset pin and requires that some specified
> time elapses after this reset pin is deasserted, before communication
> with the device is attempted.
> 
> The Linux implementation is looking for these in the "reset-gpios" and
> "post-reset-deassert-delay-ms" properties already, so use these property
> names.
> 
> Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> ---
>  Documentation/devicetree/bindings/input/hid-over-i2c.yaml | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.yaml b/Documentation/devicetree/bindings/input/hid-over-i2c.yaml
> index 138caad96a29..f07ff4cb3d26 100644
> --- a/Documentation/devicetree/bindings/input/hid-over-i2c.yaml
> +++ b/Documentation/devicetree/bindings/input/hid-over-i2c.yaml
> @@ -50,6 +50,12 @@ properties:
>      description: Time required by the device after enabling its regulators
>        or powering it on, before it is ready for communication.
>  
> +  post-reset-deassert-delay-ms:
> +    description: Time required by the device after reset has been deasserted,
> +      before it is ready for communication.

I know that Rob reluctantly acked this, but re-reading the commit
message for the commit that added support for the reset gpio to the
driver, and added a comment about this not having been added to the
devicetree binding, it becomes obvious that the latter was done on
purpose and that we probably should not be adding the
'post-reset-deassert-delay-ms' property after all:

	For now the new "post-reset-deassert-delay-ms" property is only
	used on x86/ACPI (non devicetree) devs. IOW it is not used in
	actual devicetree files and the same goes for the reset GPIO.
	The devicetree-bindings maintainers have requested properties
	like these to not be added to the devicetree-bindings, so the
	new property + GPIO are deliberately not added to the existing
	devicetree-bindings.

	2be404486c05 ("HID: i2c-hid-of: Add reset GPIO support to i2c-hid-of")

So perhaps we should just do this properly and add a new compatible
property for X13s touchscreen which can be used to determine these
delays (e.g. for cases where some default values are insufficient).

Johan

^ permalink raw reply

* Re: [PATCH] HID: i2c-hid-of: fix NULL-deref on failed power up
From: Johan Hovold @ 2024-02-01  9:55 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Johan Hovold, Jiri Kosina, Benjamin Tissoires, linux-input,
	linux-kernel, stable
In-Reply-To: <CAD=FV=UzGcneoL1d-DDXVugAeq2+YLCKrq8-5B7TfVAAKgF=SQ@mail.gmail.com>

On Fri, Jan 26, 2024 at 09:47:23AM -0800, Doug Anderson wrote:
> On Fri, Jan 26, 2024 at 9:10 AM Johan Hovold <johan+linaro@kernel.org> wrote:

> > A while back the I2C HID implementation was split in an ACPI and OF
> > part, but the new OF driver never initialises the client pointer which
> > is dereferenced on power-up failures.

> Good catch and thanks for the fix. FWIW, I'd be OK w/
> 
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
> 
> That being said, I'd be even happier if you simply removed the
> "client" from the structure and removed the error printout.
> regulator_bulk_enable() already prints error messages when a failure
> happens and thus the error printout is redundant and wastes space.

True, but that error message does not include the device that tried to
use the regulator.

I actually hit this when adding dev_dbg() to the function in question.
For such cases, it's also convenient to have struct device easily
accessible so I think it should be ok to just leave this pointer in.

Johan

^ permalink raw reply

* Re: [PATCH v7 2/3] dt-bindings: input: Add TouchNetix axiom touchscreen
From: Krzysztof Kozlowski @ 2024-02-01  8:56 UTC (permalink / raw)
  To: Kamel Bouhara, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg, linux-input, linux-kernel,
	devicetree, Marco Felsch, Jeff LaBundy
  Cc: catalin.popescu, mark.satterthwaite, Thomas Petazzoni,
	Gregory Clement, bsp-development.geo
In-Reply-To: <20240131141158.3350344-3-kamel.bouhara@bootlin.com>

On 31/01/2024 15:11, Kamel Bouhara wrote:
> Add the TouchNetix axiom I2C touchscreen device tree bindings
> documentation.
> 
> Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com>
> ---


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply

* Re: [PATCH v3 1/2] dt-bindings: HID: i2c-hid: Document reset-related properties
From: Johan Hovold @ 2024-02-01  8:15 UTC (permalink / raw)
  To: Rob Herring
  Cc: Bjorn Andersson, Dmitry Torokhov, Krzysztof Kozlowski,
	Conor Dooley, Benjamin Tissoires, Jiri Kosina, Bjorn Andersson,
	Konrad Dybcio, Johan Hovold, linux-arm-msm, linux-input,
	devicetree, linux-kernel, Konrad Dybcio, Krzysztof Kozlowski
In-Reply-To: <20240131202239.GA2222869-robh@kernel.org>

On Wed, Jan 31, 2024 at 02:22:39PM -0600, Rob Herring wrote:
> On Mon, Jan 29, 2024 at 05:56:47PM +0100, Johan Hovold wrote:
> > On Mon, Jan 29, 2024 at 08:47:47AM -0800, Bjorn Andersson wrote:
> > > Some I2C HID devices has a reset pin and requires that some specified
> > > time elapses after this reset pin is deasserted, before communication
> > > with the device is attempted.
> > > 
> > > The Linux implementation is looking for these in the "reset-gpios" and
> > > "post-reset-deassert-delay-ms" properties already, so use these property
> > > names.
> > 
> > > +  post-reset-deassert-delay-ms:
> > > +    description: Time required by the device after reset has been deasserted,
> > > +      before it is ready for communication.
> > > +
> > > +  reset-gpios: true
> > 
> > Hmm, for the third time, it seems you ignored my comment that you need
> > to remove the comment about these properties from the driver as part of
> > this series.
> > 
> > 	/*
> > 	 * Note this is a kernel internal device-property set by x86 platform code,
> > 	 * this MUST not be used in devicetree files without first adding it to
> > 	 * the DT bindings.
> > 	 */
> > 	if (!device_property_read_u32(dev, "post-reset-deassert-delay-ms", &val))
> > 		ihid_of->post_reset_delay_ms = val;
> 
> DT devices should have a specific compatible that gives enough detail to 
> handle this delay or *any* other power sequencing requirement.
> 
> OTOH, we've already got one other delay property, what's one more. Sigh.
> 
> Acked-by: Rob Herring <robh@kernel.org>

Right, and I guess we could do this now before this new property gets
more use. Who knows if those delays are actually correct or may need to
be tweaked down the line.

Apparently we only have one specific i2c-hid compatible in the kernel
(and it's not yet used by the driver).

Johan

^ permalink raw reply

* Re: [PATCH v4 2/3] HID: i2c-hid-of: Remove comment about post-reset in DT binding
From: Johan Hovold @ 2024-02-01  8:06 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold, linux-arm-msm, linux-input, devicetree,
	linux-kernel, Konrad Dybcio, Krzysztof Kozlowski
In-Reply-To: <20240131-x13s-touchscreen-v4-2-39c0f9925d3c@quicinc.com>

On Wed, Jan 31, 2024 at 07:07:27PM -0800, Bjorn Andersson wrote:
> With the "post-reset-deassert-delay-ms" property added to the DeviceTree
> binding, the comment is no longer valid, remove it.
> 
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>

Reviewed-by: Johan Hovold <johan+linaro@kernel.org>

^ permalink raw reply

* Re: [PATCH v5 3/3] Input: Add TouchNetix axiom i2c touchscreen driver
From: Kamel Bouhara @ 2024-02-01  5:09 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jeff LaBundy, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Henrik Rydberg, linux-input, linux-kernel, devicetree,
	Marco Felsch, catalin.popescu, mark.satterthwaite, bartp,
	hannah.rossiter, Thomas Petazzoni, Gregory Clement,
	bsp-development.geo
In-Reply-To: <ZbqmN47QhI1LhWBT@google.com>

On Wed, Jan 31, 2024 at 11:57:43AM -0800, Dmitry Torokhov wrote:
> On Wed, Jan 31, 2024 at 06:14:41PM +0100, Kamel Bouhara wrote:
> > On Thu, Dec 28, 2023 at 09:44:31PM -0600, Jeff LaBundy wrote:
>
> [...]
>
> > > > +	case AXIOM_TARGET_STATE_HOVER:
> > > > +	case AXIOM_TARGET_STATE_TOUCHING:
> > > > +		target_prev_state->insert = true;
> > > > +		update = true;
> > > > +		input_mt_slot(input_dev, slot);
> > > > +		input_report_abs(input_dev, ABS_MT_TRACKING_ID, slot);
> > > > +		input_report_abs(input_dev, ABS_MT_POSITION_X, target->x);
> > > > +		input_report_abs(input_dev, ABS_X, target->x);
> > >
> > > You do not need to explicitly report ABS_X and ABS_Y values, as calling
> > > input_mt_sync_frame() effectively takes care of this by way of pointer
> > > emulation.
> > >
> >
> > After double checking/testing this, it doesn't seems to
> > report ABS_X/Y values anymore, are you sure about this ? Maybe I missed
> > some extra flag in input_mt_init_slots() for that ?
>
> You are missing call to input_report_slot_state() before you start
> sending position data. You also should not conflate tracking ID and
> slot number. I.e. if you touch and release and touch again, you
> likely report through the same slot 0, but the tracking ID of the
> contact should be different.
>

Hi Dmitry,

Ok thanks for the clarification, I will check again but I think you are
right and target->index should be used as the tracking ID as it should
be different between reports.

This should be fixed in v8.

Thanks !
--
Kamel Bouhara, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

^ permalink raw reply

* [PATCH 2/2] HID: wacom: Clean up use of struct->wacom_wac
From: Tobita, Tatsunosuke @ 2024-02-01  4:43 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina
  Cc: Ping Cheng, Jason Gerecke, Aaron Armstrong Skomra, Joshua Dickens,
	Tatsunosuke Tobita

From: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>

Replace the indirect accesses to struct->wacom_wac from struct->wacom
to the direct access in order for better code reading.

Signed-off-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
---
 drivers/hid/wacom_wac.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index fbe10fbc5769..a44367aef621 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2990,11 +2990,11 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
 
 	wacom_wac_battery_pre_report(hdev, report);
 
-	if (pad_in_hid_field && wacom->wacom_wac.pad_input)
+	if (pad_in_hid_field && wacom_wac->pad_input)
 		wacom_wac_pad_pre_report(hdev, report);
-	if (pen_in_hid_field && wacom->wacom_wac.pen_input)
+	if (pen_in_hid_field && wacom_wac->pen_input)
 		wacom_wac_pen_pre_report(hdev, report);
-	if (finger_in_hid_field && wacom->wacom_wac.touch_input)
+	if (finger_in_hid_field && wacom_wac->touch_input)
 		wacom_wac_finger_pre_report(hdev, report);
 
 	for (r = 0; r < report->maxfield; r++) {
@@ -3010,7 +3010,7 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
 
 	wacom_wac_battery_report(hdev, report);
 
-	if (true_pad && wacom->wacom_wac.pad_input)
+	if (true_pad && wacom_wac->pad_input)
 		wacom_wac_pad_report(hdev, report, field);
 }
 
-- 
2.34.1


^ permalink raw reply related

* [PATCH 1/2] HID: wacom: generic: Avoid reporting a serial of '0' to userspace
From: Tobita, Tatsunosuke @ 2024-02-01  4:40 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina
  Cc: Ping Cheng, Jason Gerecke, Aaron Armstrong Skomra, Joshua Dickens,
	Tatsunosuke Tobita, Jason Gerecke, stable

From: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>

The xf86-input-wacom driver does not treat '0' as a valid serial
number and will drop any input report which contains an
MSC_SERIAL = 0 event. The kernel driver already takes care to
avoid sending any MSC_SERIAL event if the value of serial[0] == 0
(which is the case for devices that don't actually report a
serial number), but this is not quite sufficient.
Only the lower 32 bits of the serial get reported to userspace,
so if this portion of the serial is zero then there can still
be problems.

This commit allows the driver to report either the lower 32 bits
if they are non-zero or the upper 32 bits otherwise.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
Fixes: f85c9dc678a5 ("HID: wacom: generic: Support tool ID and additional tool types")
CC: stable@vger.kernel.org # v4.10
---
 drivers/hid/wacom_wac.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index da8a01fedd39..fbe10fbc5769 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2575,7 +2575,14 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
 				wacom_wac->hid_data.tipswitch);
 		input_report_key(input, wacom_wac->tool[0], sense);
 		if (wacom_wac->serial[0]) {
-			input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
+			/*
+			 * xf86-input-wacom does not accept a serial number
+			 * of '0'. Report the low 32 bits if possible, but
+			 * if they are zero, report the upper ones instead.
+			 */
+			__u32 serial_lo = wacom_wac->serial[0] & 0xFFFFFFFFu;
+			__u32 serial_hi = wacom_wac->serial[0] >> 32;
+			input_event(input, EV_MSC, MSC_SERIAL, (int)(serial_lo ? serial_lo : serial_hi));
 			input_report_abs(input, ABS_MISC, sense ? id : 0);
 		}
 
-- 
2.34.1


^ permalink raw reply related

* Re: [PATCH v4 0/3] arm64: dts: qcom: sc8280xp-x13s: Enable touchscreen
From: Steev Klimaszewski @ 2024-02-01  4:04 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold, linux-arm-msm, linux-input, devicetree,
	linux-kernel, Konrad Dybcio, Krzysztof Kozlowski, Rob Herring,
	Daniel Thompson
In-Reply-To: <20240131-x13s-touchscreen-v4-0-39c0f9925d3c@quicinc.com>

On Wed, Jan 31, 2024 at 9:07 PM Bjorn Andersson
<quic_bjorande@quicinc.com> wrote:
>
> This documents and defines the necessary properties for the I2C
> HID-based touchscreen found in some SKUs of the Lenovo Thinkpad X13s to
> work.
>
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> ---
> Changes in v4:
> - Introduced the patch in the HID driver removing the comment about the
> need to update the binding.
> - Link to v3: https://lore.kernel.org/r/20240129-x13s-touchscreen-v3-0-c4a933034145@quicinc.com
>
> Changes in v3:
> - Rewrote the commit message, to properly describe the problem being
>   resolved.
> - Link to v2: https://lore.kernel.org/r/20240126-x13s-touchscreen-v2-0-5374ccc9e10d@quicinc.com
>
> Changes in v2:
> - Dropped output-high from &ts0_default, to avoid bouncing the reset
>   line unnecessarily
> - Link to v1: https://lore.kernel.org/r/20240125-x13s-touchscreen-v1-0-ab8c882def9c@quicinc.com
>
> ---
> Bjorn Andersson (3):
>       dt-bindings: HID: i2c-hid: Document reset-related properties
>       HID: i2c-hid-of: Remove comment about post-reset in DT binding
>       arm64: dts: qcom: sc8280xp-x13s: Fix/enable touchscreen
>
>  Documentation/devicetree/bindings/input/hid-over-i2c.yaml  | 6 ++++++
>  arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 7 +++++--
>  drivers/hid/i2c-hid/i2c-hid-of.c                           | 5 -----
>  3 files changed, 11 insertions(+), 7 deletions(-)
> ---
> base-commit: 8bf1262c53f50fa91fe15d01e5ef5629db55313c
> change-id: 20240125-x13s-touchscreen-48012ff3c24e
>
> Best regards,
> --
> Bjorn Andersson <quic_bjorande@quicinc.com>
>
>
Thank you for this work!

Works great on my Thinkpad X13s
Tested-by: Steev Klimaszewski <steev@kali.org>

^ permalink raw reply

* [PATCH v4 2/3] HID: i2c-hid-of: Remove comment about post-reset in DT binding
From: Bjorn Andersson @ 2024-02-01  3:07 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold
  Cc: linux-arm-msm, linux-input, devicetree, linux-kernel,
	Konrad Dybcio, Krzysztof Kozlowski, Bjorn Andersson
In-Reply-To: <20240131-x13s-touchscreen-v4-0-39c0f9925d3c@quicinc.com>

With the "post-reset-deassert-delay-ms" property added to the DeviceTree
binding, the comment is no longer valid, remove it.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
 drivers/hid/i2c-hid/i2c-hid-of.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c
index c4e1fa0273c8..bbc2afb86eb6 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of.c
@@ -104,11 +104,6 @@ static int i2c_hid_of_probe(struct i2c_client *client)
 	if (!device_property_read_u32(dev, "post-power-on-delay-ms", &val))
 		ihid_of->post_power_delay_ms = val;
 
-	/*
-	 * Note this is a kernel internal device-property set by x86 platform code,
-	 * this MUST not be used in devicetree files without first adding it to
-	 * the DT bindings.
-	 */
 	if (!device_property_read_u32(dev, "post-reset-deassert-delay-ms", &val))
 		ihid_of->post_reset_delay_ms = val;
 

-- 
2.25.1


^ permalink raw reply related

* [PATCH v4 1/3] dt-bindings: HID: i2c-hid: Document reset-related properties
From: Bjorn Andersson @ 2024-02-01  3:07 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold
  Cc: linux-arm-msm, linux-input, devicetree, linux-kernel,
	Konrad Dybcio, Krzysztof Kozlowski, Bjorn Andersson, Rob Herring
In-Reply-To: <20240131-x13s-touchscreen-v4-0-39c0f9925d3c@quicinc.com>

Some I2C HID devices has a reset pin and requires that some specified
time elapses after this reset pin is deasserted, before communication
with the device is attempted.

The Linux implementation is looking for these in the "reset-gpios" and
"post-reset-deassert-delay-ms" properties already, so use these property
names.

Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
 Documentation/devicetree/bindings/input/hid-over-i2c.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.yaml b/Documentation/devicetree/bindings/input/hid-over-i2c.yaml
index 138caad96a29..f07ff4cb3d26 100644
--- a/Documentation/devicetree/bindings/input/hid-over-i2c.yaml
+++ b/Documentation/devicetree/bindings/input/hid-over-i2c.yaml
@@ -50,6 +50,12 @@ properties:
     description: Time required by the device after enabling its regulators
       or powering it on, before it is ready for communication.
 
+  post-reset-deassert-delay-ms:
+    description: Time required by the device after reset has been deasserted,
+      before it is ready for communication.
+
+  reset-gpios: true
+
   touchscreen-inverted-x: true
 
   touchscreen-inverted-y: true

-- 
2.25.1


^ permalink raw reply related

* [PATCH v4 3/3] arm64: dts: qcom: sc8280xp-x13s: Fix/enable touchscreen
From: Bjorn Andersson @ 2024-02-01  3:07 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold
  Cc: linux-arm-msm, linux-input, devicetree, linux-kernel,
	Konrad Dybcio, Krzysztof Kozlowski, Bjorn Andersson,
	Daniel Thompson
In-Reply-To: <20240131-x13s-touchscreen-v4-0-39c0f9925d3c@quicinc.com>

The touchscreen present on some SKUs of Lenovo Thinkpad X13s is never
detected by Linux. Power is applied and the device is brought out of
reset using the pinconfig in DeviceTree, but the read-test in
__i2c_hid_core_probe() fails to access the device, which result in probe
being aborted.

Some users have reported success after rebinding the device.

Looking to the ACPI tables, there's a 5ms after-power and a 200ms
after-reset delay. The power-supply is shared with other components, so
this is active all the way through boot. The reset GPIO, on the other
hand, is low (reset asserted) at boot, so this is first deasserted by
the implicit application of the pinconf state.

This means the time between reset deassert and __i2c_hid_core_probe() is
significantly below the value documented in the ACPI tables.

As the I2C HID binding and driver support specifying a reset gpio,
replace the pinconf-based scheme to pull the device out of reset. Then
specify the after-reset time.

The shared power rail is currently always on, but in case this ever
change, the after-power delay is added as well, to not violate the
power-on to reset-deassert timing requirement.

Fixes: 32c231385ed4 ("arm64: dts: qcom: sc8280xp: add Lenovo Thinkpad X13s devicetree")
Tested-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
 arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
index def3976bd5bb..33731b95ad51 100644
--- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
+++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
@@ -620,7 +620,6 @@ &i2c4 {
 
 	status = "okay";
 
-	/* FIXME: verify */
 	touchscreen@10 {
 		compatible = "hid-over-i2c";
 		reg = <0x10>;
@@ -630,6 +629,11 @@ touchscreen@10 {
 		vdd-supply = <&vreg_misc_3p3>;
 		vddl-supply = <&vreg_s10b>;
 
+		reset-gpios = <&tlmm 99 GPIO_ACTIVE_LOW>;
+
+		post-power-on-delay-ms = <5>;
+		post-reset-deassert-delay-ms = <200>;
+
 		pinctrl-names = "default";
 		pinctrl-0 = <&ts0_default>;
 	};
@@ -1450,7 +1454,6 @@ int-n-pins {
 		reset-n-pins {
 			pins = "gpio99";
 			function = "gpio";
-			output-high;
 			drive-strength = <16>;
 		};
 	};

-- 
2.25.1


^ permalink raw reply related

* [PATCH v4 0/3] arm64: dts: qcom: sc8280xp-x13s: Enable touchscreen
From: Bjorn Andersson @ 2024-02-01  3:07 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold
  Cc: linux-arm-msm, linux-input, devicetree, linux-kernel,
	Konrad Dybcio, Krzysztof Kozlowski, Bjorn Andersson, Rob Herring,
	Daniel Thompson

This documents and defines the necessary properties for the I2C
HID-based touchscreen found in some SKUs of the Lenovo Thinkpad X13s to
work.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
Changes in v4:
- Introduced the patch in the HID driver removing the comment about the
need to update the binding.
- Link to v3: https://lore.kernel.org/r/20240129-x13s-touchscreen-v3-0-c4a933034145@quicinc.com

Changes in v3:
- Rewrote the commit message, to properly describe the problem being
  resolved.
- Link to v2: https://lore.kernel.org/r/20240126-x13s-touchscreen-v2-0-5374ccc9e10d@quicinc.com

Changes in v2:
- Dropped output-high from &ts0_default, to avoid bouncing the reset
  line unnecessarily
- Link to v1: https://lore.kernel.org/r/20240125-x13s-touchscreen-v1-0-ab8c882def9c@quicinc.com

---
Bjorn Andersson (3):
      dt-bindings: HID: i2c-hid: Document reset-related properties
      HID: i2c-hid-of: Remove comment about post-reset in DT binding
      arm64: dts: qcom: sc8280xp-x13s: Fix/enable touchscreen

 Documentation/devicetree/bindings/input/hid-over-i2c.yaml  | 6 ++++++
 arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 7 +++++--
 drivers/hid/i2c-hid/i2c-hid-of.c                           | 5 -----
 3 files changed, 11 insertions(+), 7 deletions(-)
---
base-commit: 8bf1262c53f50fa91fe15d01e5ef5629db55313c
change-id: 20240125-x13s-touchscreen-48012ff3c24e

Best regards,
-- 
Bjorn Andersson <quic_bjorande@quicinc.com>


^ permalink raw reply

* Re: [PATCH v6 RESEND 6/6] dt-bindings: mfd: dlg,da9063: Convert da9062 to json-schema
From: Dmitry Torokhov @ 2024-01-31 23:20 UTC (permalink / raw)
  To: Biju Das
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Lee Jones,
	Support Opensource, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Steve Twiss, linux-input, devicetree, linux-pm,
	Geert Uytterhoeven, Prabhakar Mahadev Lad, Biju Das,
	linux-renesas-soc, Krzysztof Kozlowski, Conor Dooley
In-Reply-To: <20240131102656.3379-7-biju.das.jz@bp.renesas.com>

On Wed, Jan 31, 2024 at 10:26:56AM +0000, Biju Das wrote:
> Convert the da9062 PMIC device tree binding documentation to json-schema.
> 
> Document the missing gpio child node for da9062.
> 
> While at it, update description with link to product information and
> example.
> 
> The missing child node with of_compatible defined in MFD_CELL_OF is
> causing the below warning message:
> da9062-gpio: Failed to locate of_node [id: -1]
> 
> So, make all child nodes with of_compatible defined in struct mfd_cell
> as required property for da906{1,2} devices.
> 
> The "gpio-controller" and "#gpio-cells" properties are defined in the
> parent instead of gpio child node as there are existing driver users
> based on these parent properties.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> Acked-by: Lee Jones <lee@kernel.org>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v6 RESEND 3/6] dt-bindings: input: Convert da906{1,2,3} onkey to json-schema
From: Dmitry Torokhov @ 2024-01-31 23:19 UTC (permalink / raw)
  To: Biju Das
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Support Opensource, linux-input, devicetree, Geert Uytterhoeven,
	Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc, Conor Dooley,
	Krzysztof Kozlowski, Lee Jones
In-Reply-To: <20240131102656.3379-4-biju.das.jz@bp.renesas.com>

On Wed, Jan 31, 2024 at 10:26:53AM +0000, Biju Das wrote:
> Convert the da906{1,2,3} onkey device tree binding documentation to
> json-schema.
> 
> Update MAINTAINERS entries, description and onkey property by
> referring to dlg,da9062-onkey binding file.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Acked-by: Lee Jones <lee@kernel.org>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH 1/2] HID: samsung: Reduce code size
From: Joe Perches @ 2024-01-31 20:21 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Sandeep C S, Junwan Cho, Jitender Sajwan, linux-input,
	linux-kernel
In-Reply-To: <cover.1706732238.git.joe@perches.com>

Remove samsung_kbd_mouse_map_key_clear macro and uses to reduce
overall code size by ~8kb.

$ size drivers/hid/hid-samsung.o*
   text	   data	    bss	    dec	    hex	filename
   3203	    440	      0	   3643	    e3b	drivers/hid/hid-samsung.o.new
  11286	    448	      0	  11734	   2dd6	drivers/hid/hid-samsung.o.old

Consolidate multiple '&' uses.
Create and use static const struct and for loops instead of multiple calls
with hidden arguments of samsung_kbd_mouse_map_key_clear macro.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/hid/hid-samsung.c | 512 +++++++++++++++-----------------------
 1 file changed, 202 insertions(+), 310 deletions(-)

diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index 08fb25b8459af..d701dd3a914e7 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -81,8 +81,10 @@ static __u8 *samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
-#define samsung_kbd_mouse_map_key_clear(c) \
-	hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
+struct key_clear_map {
+	unsigned use;
+	__u16 kb;
+};
 
 static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
 	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
@@ -90,143 +92,101 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
 {
 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
 	unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
-
-	if (ifnum != 1 || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE))
+	int i;
+	unsigned use;
+	unsigned up = usage->hid & HID_USAGE_PAGE;
+	static const struct key_clear_map kcm[] = {
+		{ 0x183, KEY_MEDIA },
+		{ 0x195, KEY_EMAIL },
+		{ 0x196, KEY_CALC },
+		{ 0x197, KEY_COMPUTER },
+		{ 0x22b, KEY_SEARCH },
+		{ 0x22c, KEY_WWW },
+		{ 0x22d, KEY_BACK },
+		{ 0x22e, KEY_FORWARD },
+		{ 0x22f, KEY_FAVORITES },
+		{ 0x230, KEY_REFRESH },
+		{ 0x231, KEY_STOP },
+	};
+
+	if (ifnum != 1 || HID_UP_CONSUMER != up)
 		return 0;
 
+	use = usage->hid & HID_USAGE;
+
 	dbg_hid("samsung wireless keyboard/mouse input mapping event [0x%x]\n",
-		usage->hid & HID_USAGE);
-
-	switch (usage->hid & HID_USAGE) {
-	/* report 2 */
-	case 0x183:
-		samsung_kbd_mouse_map_key_clear(KEY_MEDIA);
-		break;
-	case 0x195:
-		samsung_kbd_mouse_map_key_clear(KEY_EMAIL);
-		break;
-	case 0x196:
-		samsung_kbd_mouse_map_key_clear(KEY_CALC);
-		break;
-	case 0x197:
-		samsung_kbd_mouse_map_key_clear(KEY_COMPUTER);
-		break;
-	case 0x22b:
-		samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
-		break;
-	case 0x22c:
-		samsung_kbd_mouse_map_key_clear(KEY_WWW);
-		break;
-	case 0x22d:
-		samsung_kbd_mouse_map_key_clear(KEY_BACK);
-		break;
-	case 0x22e:
-		samsung_kbd_mouse_map_key_clear(KEY_FORWARD);
-		break;
-	case 0x22f:
-		samsung_kbd_mouse_map_key_clear(KEY_FAVORITES);
-		break;
-	case 0x230:
-		samsung_kbd_mouse_map_key_clear(KEY_REFRESH);
-		break;
-	case 0x231:
-		samsung_kbd_mouse_map_key_clear(KEY_STOP);
-		break;
-	default:
-		return 0;
+		use);
+
+	for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+		if (use == kcm[i].use) {
+			hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+					    kcm[i].kb);
+			return 1;
+		}
 	}
 
-	return 1;
+	return 0;
 }
 
 static int samsung_kbd_input_mapping(struct hid_device *hdev,
 	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
 	unsigned long **bit, int *max)
 {
-	if (!(HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE) ||
-			HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)))
+	int i;
+	unsigned use;
+	unsigned up = usage->hid & HID_USAGE_PAGE;
+
+	if (!(up == HID_UP_CONSUMER || up == HID_UP_KEYBOARD))
 		return 0;
 
-	dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n",
-		usage->hid & HID_USAGE);
+	use = usage->hid & HID_USAGE;
+
+	dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n", use);
+
+	if (up == HID_UP_KEYBOARD) {
+		static const struct key_clear_map kcm[] = {
+			{ 0x32, KEY_BACKSLASH },
+			{ 0x64, KEY_102ND },
+			{ 0x87, KEY_RO },
+		};
 
-	if (HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)) {
 		set_bit(EV_REP, hi->input->evbit);
-		switch (usage->hid & HID_USAGE) {
-		case 0x32:
-			samsung_kbd_mouse_map_key_clear(KEY_BACKSLASH);
-			break;
-		case 0x64:
-			samsung_kbd_mouse_map_key_clear(KEY_102ND);
-			break;
-		/* Only for BR keyboard */
-		case 0x87:
-			samsung_kbd_mouse_map_key_clear(KEY_RO);
-			break;
-		default:
-			return 0;
+		for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+			if (use == kcm[i].use) {
+				hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+						    kcm[i].kb);
+				return 1;
+			}
 		}
+		return 0;
 	}
 
-	if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
-		switch (usage->hid & HID_USAGE) {
-		/* report 2 */
-		/* MENU */
-		case 0x040:
-			samsung_kbd_mouse_map_key_clear(KEY_MENU);
-			break;
-		case 0x18a:
-			samsung_kbd_mouse_map_key_clear(KEY_MAIL);
-			break;
-		case 0x196:
-			samsung_kbd_mouse_map_key_clear(KEY_WWW);
-			break;
-		case 0x19e:
-			samsung_kbd_mouse_map_key_clear(KEY_SCREENLOCK);
-			break;
-		case 0x221:
-			samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
-			break;
-		case 0x223:
-			samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
-			break;
-		/* Smtart Voice Key */
-		case 0x300:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY13);
-			break;
-		/* RECENTAPPS */
-		case 0x301:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY1);
-			break;
-		/* APPLICATION */
-		case 0x302:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY2);
-			break;
-		/* Voice search */
-		case 0x305:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY4);
-			break;
-		/* QPANEL on/off */
-		case 0x306:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY5);
-			break;
-		/* SIP on/off */
-		case 0x307:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY3);
-			break;
-		/* LANG */
-		case 0x308:
-			samsung_kbd_mouse_map_key_clear(KEY_LANGUAGE);
-			break;
-		case 0x30a:
-			samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSDOWN);
-			break;
-		case 0x30b:
-			samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSUP);
-			break;
-		default:
-			return 0;
+	if (up == HID_UP_CONSUMER) {
+		static const struct key_clear_map kcm[] = {
+			{ 0x040, KEY_MENU },		/* MENU */
+			{ 0x18a, KEY_MAIL },
+			{ 0x196, KEY_WWW },
+			{ 0x19e, KEY_SCREENLOCK },
+			{ 0x221, KEY_SEARCH },
+			{ 0x223, KEY_HOMEPAGE },
+			{ 0x300, BTN_TRIGGER_HAPPY13 }, /* Smtart Voice Key */
+			{ 0x301, BTN_TRIGGER_HAPPY1 },	/* RECENTAPPS */
+			{ 0x302, BTN_TRIGGER_HAPPY2 },	/* APPLICATION */
+			{ 0x305, BTN_TRIGGER_HAPPY4 },	/* Voice search */
+			{ 0x306, BTN_TRIGGER_HAPPY5 },	/* QPANEL on/off */
+			{ 0x307, BTN_TRIGGER_HAPPY3 },	/* SIP on/off */
+			{ 0x308, KEY_LANGUAGE },	/* LANG */
+			{ 0x30a, KEY_BRIGHTNESSDOWN },
+			{ 0x30b, KEY_BRIGHTNESSUP },
+		};
+		for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+			if (use == kcm[i].use) {
+				hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+						    kcm[i].kb);
+				return 1;
+			}
 		}
+		return 0;
 	}
 
 	return 1;
@@ -236,88 +196,62 @@ static int samsung_gamepad_input_mapping(struct hid_device *hdev,
 	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
 	unsigned long **bit, int *max)
 {
-	if (!(HID_UP_BUTTON == (usage->hid & HID_USAGE_PAGE) ||
-			HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)))
+	int i;
+	unsigned use;
+	unsigned up = usage->hid & HID_USAGE_PAGE;
+
+	if (!(up == HID_UP_BUTTON || up == HID_UP_CONSUMER))
 		return 0;
 
+	use = usage->hid & HID_USAGE;
+
 	dbg_hid("samsung wireless gamepad input mapping event [0x%x], %ld, %ld, [0x%x]\n",
-		usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0], usage->hid & HID_USAGE_PAGE);
-
-	if (HID_UP_BUTTON == (usage->hid & HID_USAGE_PAGE)) {
-		switch (usage->hid & HID_USAGE) {
-		case 0x01:
-			samsung_kbd_mouse_map_key_clear(BTN_A);
-			break;
-		case 0x02:
-			samsung_kbd_mouse_map_key_clear(BTN_B);
-			break;
-		case 0x03:
-			samsung_kbd_mouse_map_key_clear(BTN_C);
-			break;
-		case 0x04:
-			samsung_kbd_mouse_map_key_clear(BTN_X);
-			break;
-		case 0x05:
-			samsung_kbd_mouse_map_key_clear(BTN_Y);
-			break;
-		case 0x06:
-			samsung_kbd_mouse_map_key_clear(BTN_Z);
-			break;
-		case 0x07:
-			samsung_kbd_mouse_map_key_clear(BTN_TL);
-			break;
-		case 0x08:
-			samsung_kbd_mouse_map_key_clear(BTN_TR);
-			break;
-		case 0x09:
-			samsung_kbd_mouse_map_key_clear(BTN_TL2);
-			break;
-		case 0x0a:
-			samsung_kbd_mouse_map_key_clear(BTN_TR2);
-			break;
-		case 0x0b:
-			samsung_kbd_mouse_map_key_clear(BTN_SELECT);
-			break;
-		case 0x0c:
-			samsung_kbd_mouse_map_key_clear(BTN_START);
-			break;
-		case 0x0d:
-			samsung_kbd_mouse_map_key_clear(BTN_MODE);
-			break;
-		case 0x0e:
-			samsung_kbd_mouse_map_key_clear(BTN_THUMBL);
-			break;
-		case 0x0f:
-			samsung_kbd_mouse_map_key_clear(BTN_THUMBR);
-			break;
-		case 0x10:
-			samsung_kbd_mouse_map_key_clear(0x13f);
-			break;
-		default:
-			return 0;
+		use, hi->input->evbit[0], hi->input->absbit[0], up);
+
+	if (up == HID_UP_BUTTON) {
+		static const struct key_clear_map kcm[] = {
+			{ 0x01, BTN_A },
+			{ 0x02, BTN_B },
+			{ 0x03, BTN_C },
+			{ 0x04, BTN_X },
+			{ 0x05, BTN_Y },
+			{ 0x06, BTN_Z },
+			{ 0x07, BTN_TL },
+			{ 0x08, BTN_TR },
+			{ 0x09, BTN_TL2 },
+			{ 0x0a, BTN_TR2 },
+			{ 0x0b, BTN_SELECT },
+			{ 0x0c, BTN_START },
+			{ 0x0d, BTN_MODE },
+			{ 0x0e, BTN_THUMBL },
+			{ 0x0f, BTN_THUMBR },
+			{ 0x10, 0x13f },
+		};
+		for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+			if (use == kcm[i].use) {
+				hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+						    kcm[i].kb);
+				return 1;
+			}
 		}
+		return 0;
 	}
 
-	if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
-		switch (usage->hid & HID_USAGE) {
-		case 0x040:
-			samsung_kbd_mouse_map_key_clear(KEY_MENU);
-			break;
-		case 0x223:
-			samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
-			break;
-		case 0x224:
-			samsung_kbd_mouse_map_key_clear(KEY_BACK);
-			break;
-
-		/* Screen Capture */
-		case 0x303:
-			samsung_kbd_mouse_map_key_clear(KEY_SYSRQ);
-			break;
-
-		default:
-			return 0;
+	if (up == HID_UP_CONSUMER) {
+		static const struct key_clear_map kcm[] = {
+			{ 0x040, KEY_MENU },
+			{ 0x223, KEY_HOMEPAGE },
+			{ 0x224, KEY_BACK },
+			{ 0x303, KEY_SYSRQ },		/* Screen Capture */
+		};
+		for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+			if (use == kcm[i].use) {
+				hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+						    kcm[i].kb);
+				return 1;
+			}
 		}
+		return 0;
 	}
 
 	return 1;
@@ -327,22 +261,29 @@ static int samsung_actionmouse_input_mapping(struct hid_device *hdev,
 	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
 	unsigned long **bit, int *max)
 {
+	int i;
+	unsigned use;
+	unsigned up = usage->hid & HID_USAGE_PAGE;
+	static const struct key_clear_map kcm[] = {
+		{ 0x301, 254 },
+	};
+
+	use = usage->hid & HID_USAGE;
 
 	dbg_hid("samsung wireless actionmouse input mapping event [0x%x], [0x%x], %ld, %ld, [0x%x]\n",
-			usage->hid, usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0],
-			usage->hid & HID_USAGE_PAGE);
+		use, usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0],
+		up);
 
-	if (((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) && ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON))
+	if (!(up == HID_UP_CONSUMER || up == HID_UP_BUTTON))
 		return 0;
 
-	switch (usage->hid & HID_USAGE) {
-	case 0x301:
-		samsung_kbd_mouse_map_key_clear(254);
-		break;
-	default:
-		return 0;
+	for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+		if (use == kcm[i].use) {
+			hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+					    kcm[i].kb);
+			return 1;
+		}
 	}
-
 	return 1;
 }
 
@@ -350,120 +291,71 @@ static int samsung_universal_kbd_input_mapping(struct hid_device *hdev,
 	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
 	unsigned long **bit, int *max)
 {
-	if (!(HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE) ||
-			HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)))
+	int i;
+	unsigned use;
+	unsigned up = usage->hid & HID_USAGE_PAGE;
+
+	if (!(up == HID_UP_CONSUMER || up == HID_UP_KEYBOARD))
 		return 0;
 
-	dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n",
-		usage->hid & HID_USAGE);
+	use = usage->hid & HID_USAGE;
+
+	dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n", use);
+
+	if (up == HID_UP_KEYBOARD) {
+		static const struct key_clear_map kcm[] = {
+			{ 0x32, KEY_BACKSLASH },
+			{ 0x64, KEY_102ND },
+			{ 0x87, KEY_RO },	/* Only for BR keyboard */
+		};
 
-	if (HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)) {
 		set_bit(EV_REP, hi->input->evbit);
-		switch (usage->hid & HID_USAGE) {
-		case 0x32:
-			samsung_kbd_mouse_map_key_clear(KEY_BACKSLASH);
-			break;
-		case 0x64:
-			samsung_kbd_mouse_map_key_clear(KEY_102ND);
-			break;
-		/* Only for BR keyboard */
-		case 0x87:
-			samsung_kbd_mouse_map_key_clear(KEY_RO);
-			break;
-		default:
-			return 0;
+		for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+			if (use == kcm[i].use) {
+				hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+						    kcm[i].kb);
+				return 1;
+			}
 		}
+		return 0;
 	}
 
-	if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
-		switch (usage->hid & HID_USAGE) {
+	if (up == HID_UP_CONSUMER) {
 		/* report 2 */
-		/* MENU */
-		case 0x040:
-			samsung_kbd_mouse_map_key_clear(KEY_MENU);
-			break;
-		case 0x18a:
-			samsung_kbd_mouse_map_key_clear(KEY_MAIL);
-			break;
-		case 0x196:
-			samsung_kbd_mouse_map_key_clear(KEY_WWW);
-			break;
-		case 0x19e:
-			samsung_kbd_mouse_map_key_clear(KEY_SCREENLOCK);
-			break;
-		case 0x221:
-			samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
-			break;
-		case 0x223:
-			samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
-			break;
-		/* RECENTAPPS */
-		case 0x301:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY1);
-			break;
-		/* APPLICATION */
-		case 0x302:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY2);
-			break;
-		/* Voice search */
-		case 0x305:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY4);
-			break;
-		/* QPANEL on/off */
-		case 0x306:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY5);
-			break;
-		/* SIP on/off */
-		case 0x307:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY3);
-			break;
-		/* LANG */
-		case 0x308:
-			samsung_kbd_mouse_map_key_clear(KEY_LANGUAGE);
-			break;
-		case 0x30a:
-			samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSDOWN);
-			break;
-		case 0x070:
-			samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSDOWN);
-			break;
-		case 0x30b:
-			samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSUP);
-			break;
-		case 0x06f:
-			samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSUP);
-			break;
-		/* S-Finder */
-		case 0x304:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY7);
-			break;
-		/* Screen Capture */
-		case 0x303:
-			samsung_kbd_mouse_map_key_clear(KEY_SYSRQ);
-			break;
-		/* Multi Window */
-		case 0x309:
-			samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY9);
-			break;
-		/* HotKey App 1 */
-		case 0x071:
-			samsung_kbd_mouse_map_key_clear(0x2f5);
-			break;
-		/* HotKey App 2 */
-		case 0x072:
-			samsung_kbd_mouse_map_key_clear(0x2f6);
-			break;
-		/* HotKey App 3 */
-		case 0x073:
-			samsung_kbd_mouse_map_key_clear(0x2f7);
-			break;
-		/* Dex */
-		case 0x06e:
-			samsung_kbd_mouse_map_key_clear(0x2bd);
-			break;
-		default:
-			return 0;
+		static const struct key_clear_map kcm[] = {
+			{ 0x040, KEY_MENU },		/* MENU */
+			{ 0x18a, KEY_MAIL },
+			{ 0x196, KEY_WWW },
+			{ 0x19e, KEY_SCREENLOCK },
+			{ 0x221, KEY_SEARCH },
+			{ 0x223, KEY_HOMEPAGE },
+			{ 0x301, BTN_TRIGGER_HAPPY1 },	/* RECENTAPPS */
+			{ 0x302, BTN_TRIGGER_HAPPY2 },	/* APPLICATION */
+			{ 0x305, BTN_TRIGGER_HAPPY4 },	/* Voice search */
+			{ 0x306, BTN_TRIGGER_HAPPY5 },	/* QPANEL on/off */
+			{ 0x307, BTN_TRIGGER_HAPPY3 },	/* SIP on/off */
+			{ 0x308, KEY_LANGUAGE },	/* LANG */
+			{ 0x30a, KEY_BRIGHTNESSDOWN },
+			{ 0x070, KEY_BRIGHTNESSDOWN },
+			{ 0x30b, KEY_BRIGHTNESSUP },
+			{ 0x06f, KEY_BRIGHTNESSUP },
+			{ 0x304, BTN_TRIGGER_HAPPY7 },	/* S-Finder */
+			{ 0x303, KEY_SYSRQ },		/* Screen Capture */
+			{ 0x309, BTN_TRIGGER_HAPPY9 },	/* Multi Window */
+			{ 0x071, 0x2f5 },		/* HotKey App 1 */
+			{ 0x072, 0x2f6 },		/* HotKey App 2 */
+			{ 0x073, 0x2f7 },		/* HotKey App 3 */
+			{ 0x06e, 0x2bd },		/* Dex */
+		};
+
+		for (i = 0; i < ARRAY_SIZE(kcm); i++) {
+			if (use == kcm[i].use) {
+				hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
+						    kcm[i].kb);
+				return 1;
+			}
 		}
+		return 0;
 	}
 
 	return 1;
-- 
2.43.0


^ permalink raw reply related

* [PATCH 0/2] HID: samsung: Object code size reduction and neatening
From: Joe Perches @ 2024-01-31 20:21 UTC (permalink / raw)
  To: linux-input
  Cc: Sandeep C S, Junwan Cho, Jitender Sajwan, Jiri Kosina,
	Benjamin Tissoires, linux-kernel

Reduce object size and neatening

Joe Perches (2):
  HID: samsung: Reduce code size
  HID: samsung: Object size reduction and neatening

 drivers/hid/hid-samsung.c | 652 +++++++++++++++++---------------------
 1 file changed, 283 insertions(+), 369 deletions(-)

-- 
2.43.0


^ permalink raw reply

* Re: [PATCH v3 2/2] arm64: dts: qcom: sc8280xp-x13s: Fix/enable touchscreen
From: Rob Herring @ 2024-01-31 20:25 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Dmitry Torokhov, Krzysztof Kozlowski, Conor Dooley,
	Benjamin Tissoires, Jiri Kosina, Bjorn Andersson, Konrad Dybcio,
	Johan Hovold, linux-arm-msm, linux-input, devicetree,
	linux-kernel, Konrad Dybcio, Krzysztof Kozlowski, Daniel Thompson
In-Reply-To: <20240129-x13s-touchscreen-v3-2-c4a933034145@quicinc.com>

On Mon, Jan 29, 2024 at 08:47:48AM -0800, Bjorn Andersson wrote:
> The touchscreen present on some SKUs of Lenovo Thinkpad X13s is never
> detected by Linux. Power is applied and the device is brought out of
> reset using the pinconfig in DeviceTree, but the read-test in
> __i2c_hid_core_probe() fails to access the device, which result in probe
> being aborted.
> 
> Some users have reported success after rebinding the device.
> 
> Looking to the ACPI tables, there's a 5ms after-power and a 200ms
> after-reset delay. The power-supply is shared with other components, so
> this is active all the way through boot. The reset GPIO, on the other
> hand, is low (reset asserted) at boot, so this is first deasserted by
> the implicit application of the pinconf state.
> 
> This means the time between reset deassert and __i2c_hid_core_probe() is
> significantly below the value documented in the ACPI tables.
> 
> As the I2C HID binding and driver support specifying a reset gpio,
> replace the pinconf-based scheme to pull the device out of reset. Then
> specify the after-reset time.
> 
> The shared power rail is currently always on, but in case this ever
> change, the after-power delay is added as well, to not violate the
> power-on to reset-deassert timing requirement.
> 
> Fixes: 32c231385ed4 ("arm64: dts: qcom: sc8280xp: add Lenovo Thinkpad X13s devicetree")
> Tested-by: Daniel Thompson <daniel.thompson@linaro.org>
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> ---
>  arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> index def3976bd5bb..33731b95ad51 100644
> --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts
> @@ -620,7 +620,6 @@ &i2c4 {
>  
>  	status = "okay";
>  
> -	/* FIXME: verify */
>  	touchscreen@10 {
>  		compatible = "hid-over-i2c";

Please add a real device compatible before you need the next power 
sequencing property I'll reject.

>  		reg = <0x10>;
> @@ -630,6 +629,11 @@ touchscreen@10 {
>  		vdd-supply = <&vreg_misc_3p3>;
>  		vddl-supply = <&vreg_s10b>;
>  
> +		reset-gpios = <&tlmm 99 GPIO_ACTIVE_LOW>;
> +
> +		post-power-on-delay-ms = <5>;
> +		post-reset-deassert-delay-ms = <200>;
> +
>  		pinctrl-names = "default";
>  		pinctrl-0 = <&ts0_default>;
>  	};
> @@ -1450,7 +1454,6 @@ int-n-pins {
>  		reset-n-pins {
>  			pins = "gpio99";
>  			function = "gpio";
> -			output-high;
>  			drive-strength = <16>;
>  		};
>  	};
> 
> -- 
> 2.25.1
> 

^ permalink raw reply

* [PATCH 2/2] HID: samsung: Object size reduction and neatening
From: Joe Perches @ 2024-01-31 20:21 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Sandeep C S, Junwan Cho, Jitender Sajwan, linux-input,
	linux-kernel
In-Reply-To: <cover.1706732238.git.joe@perches.com>

Use a switch/case in samsung_input_mapping to reduce object size.

$ size drivers/hid/hid-samsung.o*
   text	   data	    bss	    dec	    hex	filename
   2842	    432	      0	   3274	    cca	drivers/hid/hid-samsung.o.new
   3203	    440	      0	   3643	    e3b	drivers/hid/hid-samsung.o.old

Miscellaneous style neatening:

o Use unsigned int instead of unsigned
o Alignment to open parenthesis
o Line wrapping

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/hid/hid-samsung.c | 166 +++++++++++++++++++++-----------------
 1 file changed, 94 insertions(+), 72 deletions(-)

diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index d701dd3a914e7..63c18b9b8279f 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -49,31 +49,35 @@
  * Report #3 has an array field with logical range 0..1 instead of 1..3.
  */
 static inline void samsung_irda_dev_trace(struct hid_device *hdev,
-		unsigned int rsize)
+					  unsigned int rsize)
 {
 	hid_info(hdev, "fixing up Samsung IrDA %d byte report descriptor\n",
 		 rsize);
 }
 
 static __u8 *samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc,
-		unsigned int *rsize)
+				       unsigned int *rsize)
 {
-	if (*rsize == 184 && !memcmp(&rdesc[175], "\x25\x40\x75\x30\x95\x01", 6) &&
-			rdesc[182] == 0x40) {
+	if (*rsize == 184 &&
+	    !memcmp(&rdesc[175], "\x25\x40\x75\x30\x95\x01", 6) &&
+	    rdesc[182] == 0x40) {
 		samsung_irda_dev_trace(hdev, 184);
 		rdesc[176] = 0xff;
 		rdesc[178] = 0x08;
 		rdesc[180] = 0x06;
 		rdesc[182] = 0x42;
-	} else if (*rsize == 203 && !memcmp(&rdesc[192], "\x15\x00\x25\x12", 4)) {
+	} else if (*rsize == 203 &&
+		   !memcmp(&rdesc[192], "\x15\x00\x25\x12", 4)) {
 		samsung_irda_dev_trace(hdev, 203);
 		rdesc[193] = 0x01;
 		rdesc[195] = 0x0f;
-	} else if (*rsize == 135 && !memcmp(&rdesc[124], "\x15\x00\x25\x11", 4)) {
+	} else if (*rsize == 135 &&
+		   !memcmp(&rdesc[124], "\x15\x00\x25\x11", 4)) {
 		samsung_irda_dev_trace(hdev, 135);
 		rdesc[125] = 0x01;
 		rdesc[127] = 0x0e;
-	} else if (*rsize == 171 && !memcmp(&rdesc[160], "\x15\x00\x25\x01", 4)) {
+	} else if (*rsize == 171 &&
+		   !memcmp(&rdesc[160], "\x15\x00\x25\x01", 4)) {
 		samsung_irda_dev_trace(hdev, 171);
 		rdesc[161] = 0x01;
 		rdesc[163] = 0x03;
@@ -82,19 +86,21 @@ static __u8 *samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 }
 
 struct key_clear_map {
-	unsigned use;
+	unsigned int use;
 	__u16 kb;
 };
 
 static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
-	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
-	unsigned long **bit, int *max)
+					   struct hid_input *hi,
+					   struct hid_field *field,
+					   struct hid_usage *usage,
+					   unsigned long **bit, int *max)
 {
 	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
 	unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
 	int i;
-	unsigned use;
-	unsigned up = usage->hid & HID_USAGE_PAGE;
+	unsigned int use;
+	unsigned int up = usage->hid & HID_USAGE_PAGE;
 	static const struct key_clear_map kcm[] = {
 		{ 0x183, KEY_MEDIA },
 		{ 0x195, KEY_EMAIL },
@@ -129,12 +135,14 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
 }
 
 static int samsung_kbd_input_mapping(struct hid_device *hdev,
-	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
-	unsigned long **bit, int *max)
+				     struct hid_input *hi,
+				     struct hid_field *field,
+				     struct hid_usage *usage,
+				     unsigned long **bit, int *max)
 {
 	int i;
-	unsigned use;
-	unsigned up = usage->hid & HID_USAGE_PAGE;
+	unsigned int use;
+	unsigned int up = usage->hid & HID_USAGE_PAGE;
 
 	if (!(up == HID_UP_CONSUMER || up == HID_UP_KEYBOARD))
 		return 0;
@@ -193,12 +201,14 @@ static int samsung_kbd_input_mapping(struct hid_device *hdev,
 }
 
 static int samsung_gamepad_input_mapping(struct hid_device *hdev,
-	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
-	unsigned long **bit, int *max)
+					 struct hid_input *hi,
+					 struct hid_field *field,
+					 struct hid_usage *usage,
+					 unsigned long **bit, int *max)
 {
 	int i;
-	unsigned use;
-	unsigned up = usage->hid & HID_USAGE_PAGE;
+	unsigned int use;
+	unsigned int up = usage->hid & HID_USAGE_PAGE;
 
 	if (!(up == HID_UP_BUTTON || up == HID_UP_CONSUMER))
 		return 0;
@@ -258,12 +268,14 @@ static int samsung_gamepad_input_mapping(struct hid_device *hdev,
 }
 
 static int samsung_actionmouse_input_mapping(struct hid_device *hdev,
-	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
-	unsigned long **bit, int *max)
+					     struct hid_input *hi,
+					     struct hid_field *field,
+					     struct hid_usage *usage,
+					     unsigned long **bit, int *max)
 {
 	int i;
-	unsigned use;
-	unsigned up = usage->hid & HID_USAGE_PAGE;
+	unsigned int use;
+	unsigned int up = usage->hid & HID_USAGE_PAGE;
 	static const struct key_clear_map kcm[] = {
 		{ 0x301, 254 },
 	};
@@ -271,7 +283,8 @@ static int samsung_actionmouse_input_mapping(struct hid_device *hdev,
 	use = usage->hid & HID_USAGE;
 
 	dbg_hid("samsung wireless actionmouse input mapping event [0x%x], [0x%x], %ld, %ld, [0x%x]\n",
-		use, usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0],
+		use, usage->hid & HID_USAGE,
+		hi->input->evbit[0], hi->input->absbit[0],
 		up);
 
 	if (!(up == HID_UP_CONSUMER || up == HID_UP_BUTTON))
@@ -288,12 +301,14 @@ static int samsung_actionmouse_input_mapping(struct hid_device *hdev,
 }
 
 static int samsung_universal_kbd_input_mapping(struct hid_device *hdev,
-	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
-	unsigned long **bit, int *max)
+					       struct hid_input *hi,
+					       struct hid_field *field,
+					       struct hid_usage *usage,
+					       unsigned long **bit, int *max)
 {
 	int i;
-	unsigned use;
-	unsigned up = usage->hid & HID_USAGE_PAGE;
+	unsigned int use;
+	unsigned int up = usage->hid & HID_USAGE_PAGE;
 
 	if (!(up == HID_UP_CONSUMER || up == HID_UP_KEYBOARD))
 		return 0;
@@ -362,43 +377,46 @@ static int samsung_universal_kbd_input_mapping(struct hid_device *hdev,
 }
 
 static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
-	unsigned int *rsize)
+				  unsigned int *rsize)
 {
-	if (hdev->product == USB_DEVICE_ID_SAMSUNG_IR_REMOTE && hid_is_usb(hdev))
+	if (hdev->product == USB_DEVICE_ID_SAMSUNG_IR_REMOTE &&
+	    hid_is_usb(hdev))
 		rdesc = samsung_irda_report_fixup(hdev, rdesc, rsize);
 	return rdesc;
 }
 
-static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
-	struct hid_field *field, struct hid_usage *usage,
-	unsigned long **bit, int *max)
+static int samsung_input_mapping(struct hid_device *hdev,
+				 struct hid_input *hi,
+				 struct hid_field *field,
+				 struct hid_usage *usage,
+				 unsigned long **bit, int *max)
 {
-	int ret = 0;
-
-	if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE && hid_is_usb(hdev))
-		ret = samsung_kbd_mouse_input_mapping(hdev,
-			hi, field, usage, bit, max);
-	else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD)
-		ret = samsung_kbd_input_mapping(hdev,
-			hi, field, usage, bit, max);
-	else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD)
-		ret = samsung_gamepad_input_mapping(hdev,
-			hi, field, usage, bit, max);
-	else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE)
-		ret = samsung_actionmouse_input_mapping(hdev,
-			hi, field, usage, bit, max);
-	else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_UNIVERSAL_KBD)
-		ret = samsung_universal_kbd_input_mapping(hdev,
-			hi, field, usage, bit, max);
-	else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_MULTI_HOGP_KBD)
-		ret = samsung_universal_kbd_input_mapping(hdev,
-			hi, field, usage, bit, max);
-
-	return ret;
+	switch (hdev->product) {
+	case USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE:
+		if (hid_is_usb(hdev))
+			return samsung_kbd_mouse_input_mapping(hdev, hi, field,
+							       usage, bit, max);
+		break;
+	case USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD:
+		return samsung_kbd_input_mapping(hdev, hi, field,
+						 usage, bit, max);
+	case USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD:
+		return samsung_gamepad_input_mapping(hdev, hi, field,
+						     usage, bit, max);
+	case USB_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE:
+		return samsung_actionmouse_input_mapping(hdev, hi, field,
+							 usage, bit, max);
+	case USB_DEVICE_ID_SAMSUNG_WIRELESS_UNIVERSAL_KBD:
+	case USB_DEVICE_ID_SAMSUNG_WIRELESS_MULTI_HOGP_KBD:
+		return samsung_universal_kbd_input_mapping(hdev, hi, field,
+							   usage, bit, max);
+	}
+
+	return 0;
 }
 
 static int samsung_probe(struct hid_device *hdev,
-		const struct hid_device_id *id)
+			 const struct hid_device_id *id)
 {
 	int ret;
 	unsigned int cmask = HID_CONNECT_DEFAULT;
@@ -406,14 +424,13 @@ static int samsung_probe(struct hid_device *hdev,
 	ret = hid_parse(hdev);
 	if (ret) {
 		hid_err(hdev, "parse failed\n");
-		goto err_free;
+		return ret;
 	}
 
 	if (hdev->product == USB_DEVICE_ID_SAMSUNG_IR_REMOTE) {
-		if (!hid_is_usb(hdev)) {
-			ret = -EINVAL;
-			goto err_free;
-		}
+		if (!hid_is_usb(hdev))
+			return -EINVAL;
+
 		if (hdev->rsize == 184) {
 			/* disable hidinput, force hiddev */
 			cmask = (cmask & ~HID_CONNECT_HIDINPUT) |
@@ -424,22 +441,27 @@ static int samsung_probe(struct hid_device *hdev,
 	ret = hid_hw_start(hdev, cmask);
 	if (ret) {
 		hid_err(hdev, "hw start failed\n");
-		goto err_free;
+		return ret;
 	}
 
 	return 0;
-err_free:
-	return ret;
 }
 
 static const struct hid_device_id samsung_devices[] = {
-	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
-	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD) },
-	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD) },
-	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE) },
-	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_UNIVERSAL_KBD) },
-	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_MULTI_HOGP_KBD) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG,
+			 USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG,
+			 USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS,
+			       USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS,
+			       USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS,
+			       USB_DEVICE_ID_SAMSUNG_WIRELESS_ACTIONMOUSE) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS,
+			       USB_DEVICE_ID_SAMSUNG_WIRELESS_UNIVERSAL_KBD) },
+	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS,
+			       USB_DEVICE_ID_SAMSUNG_WIRELESS_MULTI_HOGP_KBD) },
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, samsung_devices);
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH v3 1/2] dt-bindings: HID: i2c-hid: Document reset-related properties
From: Rob Herring @ 2024-01-31 20:22 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Bjorn Andersson, Dmitry Torokhov, Krzysztof Kozlowski,
	Conor Dooley, Benjamin Tissoires, Jiri Kosina, Bjorn Andersson,
	Konrad Dybcio, Johan Hovold, linux-arm-msm, linux-input,
	devicetree, linux-kernel, Konrad Dybcio, Krzysztof Kozlowski
In-Reply-To: <ZbfYzyHaNmjJyNpY@hovoldconsulting.com>

On Mon, Jan 29, 2024 at 05:56:47PM +0100, Johan Hovold wrote:
> On Mon, Jan 29, 2024 at 08:47:47AM -0800, Bjorn Andersson wrote:
> > Some I2C HID devices has a reset pin and requires that some specified
> > time elapses after this reset pin is deasserted, before communication
> > with the device is attempted.
> > 
> > The Linux implementation is looking for these in the "reset-gpios" and
> > "post-reset-deassert-delay-ms" properties already, so use these property
> > names.
> 
> > +  post-reset-deassert-delay-ms:
> > +    description: Time required by the device after reset has been deasserted,
> > +      before it is ready for communication.
> > +
> > +  reset-gpios: true
> 
> Hmm, for the third time, it seems you ignored my comment that you need
> to remove the comment about these properties from the driver as part of
> this series.
> 
> 	/*
> 	 * Note this is a kernel internal device-property set by x86 platform code,
> 	 * this MUST not be used in devicetree files without first adding it to
> 	 * the DT bindings.
> 	 */
> 	if (!device_property_read_u32(dev, "post-reset-deassert-delay-ms", &val))
> 		ihid_of->post_reset_delay_ms = val;

DT devices should have a specific compatible that gives enough detail to 
handle this delay or *any* other power sequencing requirement.

OTOH, we've already got one other delay property, what's one more. Sigh.

Acked-by: Rob Herring <robh@kernel.org>

Rob

^ permalink raw reply

* Re: [PATCH bpf-next v4 0/3] Annotate kfuncs in .BTF_ids section
From: patchwork-bot+netdevbpf @ 2024-01-31 20:20 UTC (permalink / raw)
  To: Daniel Xu
  Cc: linux-trace-kernel, coreteam, bpf, linux-input, cgroups, netdev,
	linux-stm32, linux-kselftest, linux-doc, fsverity, linux-kernel,
	linux-arm-kernel, netfilter-devel, alexei.starovoitov, olsajiri,
	quentin, alan.maguire, memxor
In-Reply-To: <cover.1706491398.git.dxu@dxuuu.xyz>

Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sun, 28 Jan 2024 18:24:05 -0700 you wrote:
> === Description ===
> 
> This is a bpf-treewide change that annotates all kfuncs as such inside
> .BTF_ids. This annotation eventually allows us to automatically generate
> kfunc prototypes from bpftool.
> 
> We store this metadata inside a yet-unused flags field inside struct
> btf_id_set8 (thanks Kumar!). pahole will be taught where to look.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v4,1/3] bpf: btf: Support flags for BTF_SET8 sets
    https://git.kernel.org/bpf/bpf-next/c/79b47344bbc5
  - [bpf-next,v4,2/3] bpf: btf: Add BTF_KFUNCS_START/END macro pair
    https://git.kernel.org/bpf/bpf-next/c/2747e0ee57c2
  - [bpf-next,v4,3/3] bpf: treewide: Annotate BPF kfuncs in BTF
    https://git.kernel.org/bpf/bpf-next/c/6e7769e6419f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply

* Re: [PATCH v5 3/3] Input: Add TouchNetix axiom i2c touchscreen driver
From: Dmitry Torokhov @ 2024-01-31 19:57 UTC (permalink / raw)
  To: Kamel Bouhara
  Cc: Jeff LaBundy, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Henrik Rydberg, linux-input, linux-kernel, devicetree,
	Marco Felsch, catalin.popescu, mark.satterthwaite, bartp,
	hannah.rossiter, Thomas Petazzoni, Gregory Clement,
	bsp-development.geo
In-Reply-To: <20240131171441.GA3005@kb-xps>

On Wed, Jan 31, 2024 at 06:14:41PM +0100, Kamel Bouhara wrote:
> On Thu, Dec 28, 2023 at 09:44:31PM -0600, Jeff LaBundy wrote:

[...]

> > > +	case AXIOM_TARGET_STATE_HOVER:
> > > +	case AXIOM_TARGET_STATE_TOUCHING:
> > > +		target_prev_state->insert = true;
> > > +		update = true;
> > > +		input_mt_slot(input_dev, slot);
> > > +		input_report_abs(input_dev, ABS_MT_TRACKING_ID, slot);
> > > +		input_report_abs(input_dev, ABS_MT_POSITION_X, target->x);
> > > +		input_report_abs(input_dev, ABS_X, target->x);
> >
> > You do not need to explicitly report ABS_X and ABS_Y values, as calling
> > input_mt_sync_frame() effectively takes care of this by way of pointer
> > emulation.
> >
> 
> After double checking/testing this, it doesn't seems to
> report ABS_X/Y values anymore, are you sure about this ? Maybe I missed
> some extra flag in input_mt_init_slots() for that ?

You are missing call to input_report_slot_state() before you start
sending position data. You also should not conflate tracking ID and
slot number. I.e. if you touch and release and touch again, you
likely report through the same slot 0, but the tracking ID of the
contact should be different.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: Suspected bug in hid-microsoft.c
From: Taco Jerkface @ 2024-01-31 19:27 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Siarhei Vishniakou, linux-input, jikos
In-Reply-To: <CAO-hwJ+OFxRqoL4RYaKMR_PfmpBJuyWUGcDXRrp7jWuYfT=CyQ@mail.gmail.com>

Thanks for the response!
I put some diagnostic info below, but please let me know if I can do
anything else to help.
Thank you.

hid-recorder does not see the controller when connected with USB.

sudo hid-recorder
Available devices:
/dev/hidraw0:   DLL07D1:01 044E:120B
Select the device event number [0-0]:


When connected with Bluetooth, hid-recorder sees the device as "Xbox
Wireless Controler" and the dump is below:

sudo hid-recorder
Available devices:
/dev/hidraw0:   DLL07D1:01 044E:120B
/dev/hidraw1:   Xbox Wireless Controller
Select the device event number [0-1]: 1
# Xbox Wireless Controller
# 0x05, 0x01,                    // Usage Page (Generic Desktop)        0
# 0x09, 0x05,                    // Usage (Game Pad)                    2
# 0xa1, 0x01,                    // Collection (Application)            4
# 0x85, 0x01,                    //  Report ID (1)                      6
# 0x09, 0x01,                    //  Usage (Pointer)                    8
# 0xa1, 0x00,                    //  Collection (Physical)              10
# 0x09, 0x30,                    //   Usage (X)                         12
# 0x09, 0x31,                    //   Usage (Y)                         14
# 0x15, 0x00,                    //   Logical Minimum (0)               16
# 0x27, 0xff, 0xff, 0x00, 0x00,  //   Logical Maximum (65535)           18
# 0x95, 0x02,                    //   Report Count (2)                  23
# 0x75, 0x10,                    //   Report Size (16)                  25
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              27
# 0xc0,                          //  End Collection                     29
# 0x09, 0x01,                    //  Usage (Pointer)                    30
# 0xa1, 0x00,                    //  Collection (Physical)              32
# 0x09, 0x32,                    //   Usage (Z)                         34
# 0x09, 0x35,                    //   Usage (Rz)                        36
# 0x15, 0x00,                    //   Logical Minimum (0)               38
# 0x27, 0xff, 0xff, 0x00, 0x00,  //   Logical Maximum (65535)           40
# 0x95, 0x02,                    //   Report Count (2)                  45
# 0x75, 0x10,                    //   Report Size (16)                  47
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              49
# 0xc0,                          //  End Collection                     51
# 0x05, 0x02,                    //  Usage Page (Simulation Controls)   52
# 0x09, 0xc5,                    //  Usage (Brake)                      54
# 0x15, 0x00,                    //  Logical Minimum (0)                56
# 0x26, 0xff, 0x03,              //  Logical Maximum (1023)             58
# 0x95, 0x01,                    //  Report Count (1)                   61
# 0x75, 0x0a,                    //  Report Size (10)                   63
# 0x81, 0x02,                    //  Input (Data,Var,Abs)               65
# 0x15, 0x00,                    //  Logical Minimum (0)                67
# 0x25, 0x00,                    //  Logical Maximum (0)                69
# 0x75, 0x06,                    //  Report Size (6)                    71
# 0x95, 0x01,                    //  Report Count (1)                   73
# 0x81, 0x03,                    //  Input (Cnst,Var,Abs)               75
# 0x05, 0x02,                    //  Usage Page (Simulation Controls)   77
# 0x09, 0xc4,                    //  Usage (Accelerator)                79
# 0x15, 0x00,                    //  Logical Minimum (0)                81
# 0x26, 0xff, 0x03,              //  Logical Maximum (1023)             83
# 0x95, 0x01,                    //  Report Count (1)                   86
# 0x75, 0x0a,                    //  Report Size (10)                   88
# 0x81, 0x02,                    //  Input (Data,Var,Abs)               90
# 0x15, 0x00,                    //  Logical Minimum (0)                92
# 0x25, 0x00,                    //  Logical Maximum (0)                94
# 0x75, 0x06,                    //  Report Size (6)                    96
# 0x95, 0x01,                    //  Report Count (1)                   98
# 0x81, 0x03,                    //  Input (Cnst,Var,Abs)               100
# 0x05, 0x01,                    //  Usage Page (Generic Desktop)       102
# 0x09, 0x39,                    //  Usage (Hat switch)                 104
# 0x15, 0x01,                    //  Logical Minimum (1)                106
# 0x25, 0x08,                    //  Logical Maximum (8)                108
# 0x35, 0x00,                    //  Physical Minimum (0)               110
# 0x46, 0x3b, 0x01,              //  Physical Maximum (315)             112
# 0x66, 0x14, 0x00,              //  Unit (EnglishRotation: deg)        115
# 0x75, 0x04,                    //  Report Size (4)                    118
# 0x95, 0x01,                    //  Report Count (1)                   120
# 0x81, 0x42,                    //  Input (Data,Var,Abs,Null)          122
# 0x75, 0x04,                    //  Report Size (4)                    124
# 0x95, 0x01,                    //  Report Count (1)                   126
# 0x15, 0x00,                    //  Logical Minimum (0)                128
# 0x25, 0x00,                    //  Logical Maximum (0)                130
# 0x35, 0x00,                    //  Physical Minimum (0)               132
# 0x45, 0x00,                    //  Physical Maximum (0)               134
# 0x65, 0x00,                    //  Unit (None)                        136
# 0x81, 0x03,                    //  Input (Cnst,Var,Abs)               138
# 0x05, 0x09,                    //  Usage Page (Button)                140
# 0x19, 0x01,                    //  Usage Minimum (1)                  142
# 0x29, 0x0f,                    //  Usage Maximum (15)                 144
# 0x15, 0x00,                    //  Logical Minimum (0)                146
# 0x25, 0x01,                    //  Logical Maximum (1)                148
# 0x75, 0x01,                    //  Report Size (1)                    150
# 0x95, 0x0f,                    //  Report Count (15)                  152
# 0x81, 0x02,                    //  Input (Data,Var,Abs)               154
# 0x15, 0x00,                    //  Logical Minimum (0)                156
# 0x25, 0x00,                    //  Logical Maximum (0)                158
# 0x75, 0x01,                    //  Report Size (1)                    160
# 0x95, 0x01,                    //  Report Count (1)                   162
# 0x81, 0x03,                    //  Input (Cnst,Var,Abs)               164
# 0x05, 0x0c,                    //  Usage Page (Consumer Devices)      166
# 0x0a, 0xb2, 0x00,              //  Usage (Record)                     168
# 0x15, 0x00,                    //  Logical Minimum (0)                171
# 0x25, 0x01,                    //  Logical Maximum (1)                173
# 0x95, 0x01,                    //  Report Count (1)                   175
# 0x75, 0x01,                    //  Report Size (1)                    177
# 0x81, 0x02,                    //  Input (Data,Var,Abs)               179
# 0x15, 0x00,                    //  Logical Minimum (0)                181
# 0x25, 0x00,                    //  Logical Maximum (0)                183
# 0x75, 0x07,                    //  Report Size (7)                    185
# 0x95, 0x01,                    //  Report Count (1)                   187
# 0x81, 0x03,                    //  Input (Cnst,Var,Abs)               189
# 0x05, 0x0c,                    //  Usage Page (Consumer Devices)      191
# 0x09, 0x01,                    //  Usage (Consumer Control)           193
# 0xa1, 0x01,                    //  Collection (Application)           195
# 0x0a, 0x85, 0x00,              //   Usage (Order Movie)               197
# 0x15, 0x00,                    //   Logical Minimum (0)               200
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             202
# 0x95, 0x01,                    //   Report Count (1)                  205
# 0x75, 0x08,                    //   Report Size (8)                   207
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              209
# 0x0a, 0x99, 0x00,              //   Usage (Media Select Security)     211
# 0x15, 0x00,                    //   Logical Minimum (0)               214
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             216
# 0x95, 0x01,                    //   Report Count (1)                  219
# 0x75, 0x04,                    //   Report Size (4)                   221
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              223
# 0x15, 0x00,                    //   Logical Minimum (0)               225
# 0x25, 0x00,                    //   Logical Maximum (0)               227
# 0x95, 0x01,                    //   Report Count (1)                  229
# 0x75, 0x04,                    //   Report Size (4)                   231
# 0x81, 0x03,                    //   Input (Cnst,Var,Abs)              233
# 0x0a, 0x81, 0x00,              //   Usage (Assign Selection)          235
# 0x15, 0x00,                    //   Logical Minimum (0)               238
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             240
# 0x95, 0x01,                    //   Report Count (1)                  243
# 0x75, 0x04,                    //   Report Size (4)                   245
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              247
# 0x15, 0x00,                    //   Logical Minimum (0)               249
# 0x25, 0x00,                    //   Logical Maximum (0)               251
# 0x95, 0x01,                    //   Report Count (1)                  253
# 0x75, 0x04,                    //   Report Size (4)                   255
# 0x81, 0x03,                    //   Input (Cnst,Var,Abs)              257
# 0xc0,                          //  End Collection                     259
# 0x05, 0x0f,                    //  Usage Page (Vendor Usage Page 0x0f) 260
# 0x09, 0x21,                    //  Usage (Vendor Usage 0x21)          262
# 0x85, 0x03,                    //  Report ID (3)                      264
# 0xa1, 0x02,                    //  Collection (Logical)               266
# 0x09, 0x97,                    //   Usage (Vendor Usage 0x97)         268
# 0x15, 0x00,                    //   Logical Minimum (0)               270
# 0x25, 0x01,                    //   Logical Maximum (1)               272
# 0x75, 0x04,                    //   Report Size (4)                   274
# 0x95, 0x01,                    //   Report Count (1)                  276
# 0x91, 0x02,                    //   Output (Data,Var,Abs)             278
# 0x15, 0x00,                    //   Logical Minimum (0)               280
# 0x25, 0x00,                    //   Logical Maximum (0)               282
# 0x75, 0x04,                    //   Report Size (4)                   284
# 0x95, 0x01,                    //   Report Count (1)                  286
# 0x91, 0x03,                    //   Output (Cnst,Var,Abs)             288
# 0x09, 0x70,                    //   Usage (Vendor Usage 0x70)         290
# 0x15, 0x00,                    //   Logical Minimum (0)               292
# 0x25, 0x64,                    //   Logical Maximum (100)             294
# 0x75, 0x08,                    //   Report Size (8)                   296
# 0x95, 0x04,                    //   Report Count (4)                  298
# 0x91, 0x02,                    //   Output (Data,Var,Abs)             300
# 0x09, 0x50,                    //   Usage (Vendor Usage 0x50)         302
# 0x66, 0x01, 0x10,              //   Unit (SILinear: s)                304
# 0x55, 0x0e,                    //   Unit Exponent (-2)                307
# 0x15, 0x00,                    //   Logical Minimum (0)               309
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             311
# 0x75, 0x08,                    //   Report Size (8)                   314
# 0x95, 0x01,                    //   Report Count (1)                  316
# 0x91, 0x02,                    //   Output (Data,Var,Abs)             318
# 0x09, 0xa7,                    //   Usage (Vendor Usage 0xa7)         320
# 0x15, 0x00,                    //   Logical Minimum (0)               322
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             324
# 0x75, 0x08,                    //   Report Size (8)                   327
# 0x95, 0x01,                    //   Report Count (1)                  329
# 0x91, 0x02,                    //   Output (Data,Var,Abs)             331
# 0x65, 0x00,                    //   Unit (None)                       333
# 0x55, 0x00,                    //   Unit Exponent (0)                 335
# 0x09, 0x7c,                    //   Usage (Vendor Usage 0x7c)         337
# 0x15, 0x00,                    //   Logical Minimum (0)               339
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             341
# 0x75, 0x08,                    //   Report Size (8)                   344
# 0x95, 0x01,                    //   Report Count (1)                  346
# 0x91, 0x02,                    //   Output (Data,Var,Abs)             348
# 0xc0,                          //  End Collection                     350
# 0x05, 0x0c,                    //  Usage Page (Consumer Devices)      351
# 0x09, 0x01,                    //  Usage (Consumer Control)           353
# 0x85, 0x0c,                    //  Report ID (12)                     355
# 0xa1, 0x01,                    //  Collection (Application)           357
# 0x0a, 0x9e, 0x00,              //   Usage (Media Select SAP)          359
# 0x15, 0x00,                    //   Logical Minimum (0)               362
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             364
# 0x95, 0x01,                    //   Report Count (1)                  367
# 0x75, 0x08,                    //   Report Size (8)                   369
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              371
# 0x0a, 0xa1, 0x00,              //   Usage (Once)                      373
# 0x15, 0x00,                    //   Logical Minimum (0)               376
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             378
# 0x95, 0x01,                    //   Report Count (1)                  381
# 0x75, 0x08,                    //   Report Size (8)                   383
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              385
# 0x0a, 0xa2, 0x00,              //   Usage (Daily)                     387
# 0x15, 0x00,                    //   Logical Minimum (0)               390
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             392
# 0x95, 0x01,                    //   Report Count (1)                  395
# 0x75, 0x08,                    //   Report Size (8)                   397
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              399
# 0x0a, 0xa3, 0x00,              //   Usage (Weekly)                    401
# 0x15, 0x00,                    //   Logical Minimum (0)               404
# 0x26, 0xff, 0x00,              //   Logical Maximum (255)             406
# 0x95, 0x01,                    //   Report Count (1)                  409
# 0x75, 0x08,                    //   Report Size (8)                   411
# 0x81, 0x02,                    //   Input (Data,Var,Abs)              413
# 0xc0,                          //  End Collection                     415
# 0xc0,                          // End Collection                      416
# 0x05, 0x01,                    // Usage Page (Generic Desktop)        417
# 0x09, 0x06,                    // Usage (Keyboard)                    419
# 0xa1, 0x01,                    // Collection (Application)            421
# 0x85, 0x05,                    //  Report ID (5)                      423
# 0x05, 0x07,                    //  Usage Page (Keyboard)              425
# 0x19, 0xe0,                    //  Usage Minimum (224)                427
# 0x29, 0xe7,                    //  Usage Maximum (231)                429
# 0x15, 0x00,                    //  Logical Minimum (0)                431
# 0x25, 0x01,                    //  Logical Maximum (1)                433
# 0x75, 0x01,                    //  Report Size (1)                    435
# 0x95, 0x08,                    //  Report Count (8)                   437
# 0x81, 0x02,                    //  Input (Data,Var,Abs)               439
# 0x95, 0x01,                    //  Report Count (1)                   441
# 0x75, 0x08,                    //  Report Size (8)                    443
# 0x81, 0x03,                    //  Input (Cnst,Var,Abs)               445
# 0x95, 0x06,                    //  Report Count (6)                   447
# 0x75, 0x08,                    //  Report Size (8)                    449
# 0x15, 0x00,                    //  Logical Minimum (0)                451
# 0x25, 0x65,                    //  Logical Maximum (101)              453
# 0x05, 0x07,                    //  Usage Page (Keyboard)              455
# 0x19, 0x00,                    //  Usage Minimum (0)                  457
# 0x29, 0x65,                    //  Usage Maximum (101)                459
# 0x81, 0x00,                    //  Input (Data,Arr,Abs)               461
# 0xc0,                          // End Collection                      463
#
R: 464 05 01 09 05 a1 01 85 01 09 01 a1 00 09 30 09 31 15 00 27 ff ff
00 00 95 02 75 10 81 02 c0 09 01 a1 00 09 32 09 35 15 00 27 ff ff 00
00 95 02 75 10 81 02 c0 05 02 09 c5 15 00 26 ff 03 95 01 75 0a
81 02 15 00 25 00 75 06 95 01 81 03 05 02 09 c4 15 00 26 ff 03 95 01
75 0a 81 02 15 00 25 00 75 06 95 01 81 03 05 01 09 39 15 01 25 08 35
00 46 3b 01 66 14 00 75 04 95 01 81 42 75 04 95 01 15 00 25 00
35 00 45 00 65 00 81 03 05 09 19 01 29 0f 15 00 25 01 75 01 95 0f 81
02 15 00 25 00 75 01 95 01 81 03 05 0c 0a b2 00 15 00 25 01 95 01 75
01 81 02 15 00 25 00 75 07 95 01 81 03 05 0c 09 01 a1 01 0a 85
00 15 00 26 ff 00 95 01 75 08 81 02 0a 99 00 15 00 26 ff 00 95 01 75
04 81 02 15 00 25 00 95 01 75 04 81 03 0a 81 00 15 00 26 ff 00 95 01
75 04 81 02 15 00 25 00 95 01 75 04 81 03 c0 05 0f 09 21 85 03
a1 02 09 97 15 00 25 01 75 04 95 01 91 02 15 00 25 00 75 04 95 01 91
03 09 70 15 00 25 64 75 08 95 04 91 02 09 50 66 01 10 55 0e 15 00 26
ff 00 75 08 95 01 91 02 09 a7 15 00 26 ff 00 75 08 95 01 91 02
65 00 55 00 09 7c 15 00 26 ff 00 75 08 95 01 91 02 c0 05 0c 09 01 85
0c a1 01 0a 9e 00 15 00 26 ff 00 95 01 75 08 81 02 0a a1 00 15 00 26
ff 00 95 01 75 08 81 02 0a a2 00 15 00 26 ff 00 95 01 75 08 81
02 0a a3 00 15 00 26 ff 00 95 01 75 08 81 02 c0 c0 05 01 09 06 a1 01
85 05 05 07 19 e0 29 e7 15 00 25 01 75 01 95 08 81 02 95 01 75 08 81
03 95 06 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0
N: Xbox Wireless Controller
I: 5 045e 0b22

On Wed, Jan 31, 2024 at 2:57 AM Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
>
> Hi,
>
> [Adding Siarhei who added support for those controllers in the kernel]
>
> On Wed, Jan 31, 2024 at 7:27 AM Taco Jerkface <tacodog311@gmail.com> wrote:
> >
> > Resending without HTML:
> >
> > Hi,
> >
> > I hope this is the correct contact for this report, I found you as the
> > maintainer in the hid-microsoft.c.
> >
> > I believe there is a bug in the microsoft bluetooth driver for the
> > Xbox Elite Series 2 controller.  I have been experiencing issues with
> > it that I initially thought were SDL related.  However the SDL team
> > seems to think this is driver related. My SDL bug report information
> > is here:
> >
> > https://github.com/libsdl-org/SDL/issues/8907
>
> Hard to say anything with that bug report because we don't know what
> those tools are supposed to do, and how they access the device (hidraw
> or evdev).
>
> Note that the bluetooth version is using uhid because it's a BLE controller.
> Basically when there is a BLE controller, bluez handles the transport
> layer from userspace, and injects the events through uhid so that it's
> handled as a normal kernel device.
>
> So there is no "uhid userspace driver", bluez just blindly forwards
> the events/reports/commands as it is told.
>
> >
> > Basically, SDL reads the controller correctly when connected by USB,
> > and if I run "controllermap" with root permission, but with user
> > permissions it misreads
>
> Using root or not shouldn't change the way your program sees the
> device: if you are capable of opening it, then you should get the same
> output.
>
> However, the immediate explanation that would come to my mind is that
> you are not using the "same" controller in both cases:
> - maybe that when you use it with root you are talking to the device
> through hidraw
> - maybe when you are not root you are talking to the device through evdev
>
> Again, not knowing the tools doesn't help me here :(
>
> >  the number of buttons as 122, the first paddle
> > button on the back seems to act like the "screenshot" button from the
> > 1914 controller, and the other paddle buttons are not read.  All
> > buttons read fine with evites, but the paddle buttons "KEY_UNKNOWN"
> >
> > type 1 (EV_KEY), code 240 (KEY_UNKNOWN), value 0
> >
> > Please let me know if there is a better contact for this, or if there
> > is anything I can do to help identify the problem.
> >
>
> Ideally I'd like Siarhei to answer here. But in the meantime, we could
> fetch some logs from the device itself which would allow me to better
> understand the issue:
> please use hid-recorder from hid-tools[1] to get the logs, and attach
> the whole output, with a recording of the events that are problematic:
> $> pip3 install hid-tools
> $> sudo hid-recorder
>
> Please dump 2 hid-recorder outputs, one with USB, and one with
> Bluetooth, with the same event sequence if possible so we can compare
> between the 2.
>
> Cheers,
> Benjamin
>
> [1] https://gitlab.freedesktop.org/libevdev/hid-tools
>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox