* [PATCH HID 09/13] selftests/hid: add subprog call test
From: Benjamin Tissoires @ 2024-05-28 13:14 UTC (permalink / raw)
To: Shuah Khan, Jiri Kosina, Jonathan Corbet, Alexei Starovoitov
Cc: linux-kselftest, linux-kernel, bpf, linux-input, linux-doc,
Benjamin Tissoires
In-Reply-To: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@kernel.org>
I got a weird verifier error with a subprog once, so let's have a test
for it.
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
tools/testing/selftests/hid/hid_bpf.c | 41 +++++++++++++++++++++++++++++++++
tools/testing/selftests/hid/progs/hid.c | 24 +++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c
index 967dfe6b58cb..45e173db35bd 100644
--- a/tools/testing/selftests/hid/hid_bpf.c
+++ b/tools/testing/selftests/hid/hid_bpf.c
@@ -638,6 +638,47 @@ TEST_F(hid_bpf, raw_event)
ASSERT_EQ(buf[2], 52);
}
+/*
+ * Attach hid_first_event to the given uhid device,
+ * retrieve and open the matching hidraw node,
+ * inject one event in the uhid device,
+ * check that the program sees it and can change the data
+ */
+TEST_F(hid_bpf, subprog_raw_event)
+{
+ const struct test_program progs[] = {
+ { .name = "hid_subprog_first_event" },
+ };
+ __u8 buf[10] = {0};
+ int err;
+
+ LOAD_PROGRAMS(progs);
+
+ /* inject one event */
+ buf[0] = 1;
+ buf[1] = 42;
+ uhid_send_event(_metadata, self->uhid_fd, buf, 6);
+
+ /* read the data from hidraw */
+ memset(buf, 0, sizeof(buf));
+ err = read(self->hidraw_fd, buf, sizeof(buf));
+ ASSERT_EQ(err, 6) TH_LOG("read_hidraw");
+ ASSERT_EQ(buf[0], 1);
+ ASSERT_EQ(buf[2], 47);
+
+ /* inject another event */
+ memset(buf, 0, sizeof(buf));
+ buf[0] = 1;
+ buf[1] = 47;
+ uhid_send_event(_metadata, self->uhid_fd, buf, 6);
+
+ /* read the data from hidraw */
+ memset(buf, 0, sizeof(buf));
+ err = read(self->hidraw_fd, buf, sizeof(buf));
+ ASSERT_EQ(err, 6) TH_LOG("read_hidraw");
+ ASSERT_EQ(buf[2], 52);
+}
+
/*
* Ensures that we can attach/detach programs
*/
diff --git a/tools/testing/selftests/hid/progs/hid.c b/tools/testing/selftests/hid/progs/hid.c
index 9adace26e8aa..efa3c7d292bc 100644
--- a/tools/testing/selftests/hid/progs/hid.c
+++ b/tools/testing/selftests/hid/progs/hid.c
@@ -35,6 +35,30 @@ struct hid_bpf_ops first_event = {
.hid_id = 2,
};
+int __hid_subprog_first_event(struct hid_bpf_ctx *hid_ctx, enum hid_report_type type)
+{
+ __u8 *rw_data = hid_bpf_get_data(hid_ctx, 0 /* offset */, 3 /* size */);
+
+ if (!rw_data)
+ return 0; /* EPERM check */
+
+ rw_data[2] = rw_data[1] + 5;
+
+ return hid_ctx->size;
+}
+
+SEC("?struct_ops/hid_device_event")
+int BPF_PROG(hid_subprog_first_event, struct hid_bpf_ctx *hid_ctx, enum hid_report_type type)
+{
+ return __hid_subprog_first_event(hid_ctx, type);
+}
+
+SEC(".struct_ops.link")
+struct hid_bpf_ops subprog_first_event = {
+ .hid_device_event = (void *)hid_subprog_first_event,
+ .hid_id = 2,
+};
+
SEC("?struct_ops/hid_device_event")
int BPF_PROG(hid_second_event, struct hid_bpf_ctx *hid_ctx, enum hid_report_type type)
{
--
2.44.0
^ permalink raw reply related
* [PATCH HID 10/13] Documentation: HID: amend HID-BPF for struct_ops
From: Benjamin Tissoires @ 2024-05-28 13:14 UTC (permalink / raw)
To: Shuah Khan, Jiri Kosina, Jonathan Corbet, Alexei Starovoitov
Cc: linux-kselftest, linux-kernel, bpf, linux-input, linux-doc,
Benjamin Tissoires
In-Reply-To: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@kernel.org>
Now that we are using struct_ops, the docs need to be changed.
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
Documentation/hid/hid-bpf.rst | 145 +++++++++++++++++++-----------------------
include/linux/hid_bpf.h | 8 +--
2 files changed, 71 insertions(+), 82 deletions(-)
diff --git a/Documentation/hid/hid-bpf.rst b/Documentation/hid/hid-bpf.rst
index 0765b3298ecf..bb8457bf15dd 100644
--- a/Documentation/hid/hid-bpf.rst
+++ b/Documentation/hid/hid-bpf.rst
@@ -132,16 +132,17 @@ input events.
Available types of programs
===========================
-HID-BPF is built "on top" of BPF, meaning that we use tracing method to
+HID-BPF is built "on top" of BPF, meaning that we use bpf struct_ops method to
declare our programs.
HID-BPF has the following attachment types available:
-1. event processing/filtering with ``SEC("fmod_ret/hid_bpf_device_event")`` in libbpf
+1. event processing/filtering with ``SEC("struct_ops/hid_device_event")`` in libbpf
2. actions coming from userspace with ``SEC("syscall")`` in libbpf
-3. change of the report descriptor with ``SEC("fmod_ret/hid_bpf_rdesc_fixup")`` in libbpf
+3. change of the report descriptor with ``SEC("struct_ops/hid_rdesc_fixup")`` or
+ ``SEC("struct_ops.s/hid_rdesc_fixup")`` in libbpf
-A ``hid_bpf_device_event`` is calling a BPF program when an event is received from
+A ``hid_device_event`` is calling a BPF program when an event is received from
the device. Thus we are in IRQ context and can act on the data or notify userspace.
And given that we are in IRQ context, we can not talk back to the device.
@@ -149,37 +150,42 @@ A ``syscall`` means that userspace called the syscall ``BPF_PROG_RUN`` facility.
This time, we can do any operations allowed by HID-BPF, and talking to the device is
allowed.
-Last, ``hid_bpf_rdesc_fixup`` is different from the others as there can be only one
+Last, ``hid_rdesc_fixup`` is different from the others as there can be only one
BPF program of this type. This is called on ``probe`` from the driver and allows to
-change the report descriptor from the BPF program. Once a ``hid_bpf_rdesc_fixup``
+change the report descriptor from the BPF program. Once a ``hid_rdesc_fixup``
program has been loaded, it is not possible to overwrite it unless the program which
inserted it allows us by pinning the program and closing all of its fds pointing to it.
+Note that ``hid_rdesc_fixup`` can be declared as sleepable (``SEC("struct_ops.s/hid_rdesc_fixup")``).
+
+
Developer API:
==============
-User API data structures available in programs:
------------------------------------------------
+Available ``struct_ops`` for HID-BPF:
+-------------------------------------
.. kernel-doc:: include/linux/hid_bpf.h
+ :identifiers: hid_bpf_ops
-Available tracing functions to attach a HID-BPF program:
---------------------------------------------------------
-.. kernel-doc:: drivers/hid/bpf/hid_bpf_dispatch.c
- :functions: hid_bpf_device_event hid_bpf_rdesc_fixup
+User API data structures available in programs:
+-----------------------------------------------
+
+.. kernel-doc:: include/linux/hid_bpf.h
+ :identifiers: hid_bpf_ctx hid_bpf_attach_flags
-Available API that can be used in all HID-BPF programs:
--------------------------------------------------------
+Available API that can be used in all HID-BPF struct_ops programs:
+------------------------------------------------------------------
.. kernel-doc:: drivers/hid/bpf/hid_bpf_dispatch.c
- :functions: hid_bpf_get_data
+ :identifiers: hid_bpf_get_data
-Available API that can be used in syscall HID-BPF programs:
------------------------------------------------------------
+Available API that can be used in syscall HID-BPF programs or in sleepable HID-BPF struct_ops programs:
+-------------------------------------------------------------------------------------------------------
.. kernel-doc:: drivers/hid/bpf/hid_bpf_dispatch.c
- :functions: hid_bpf_attach_prog hid_bpf_hw_request hid_bpf_hw_output_report hid_bpf_input_report hid_bpf_allocate_context hid_bpf_release_context
+ :identifiers: hid_bpf_hw_request hid_bpf_hw_output_report hid_bpf_input_report hid_bpf_allocate_context hid_bpf_release_context
General overview of a HID-BPF program
=====================================
@@ -222,8 +228,10 @@ This allows the following:
Effect of a HID-BPF program
---------------------------
-For all HID-BPF attachment types except for :c:func:`hid_bpf_rdesc_fixup`, several eBPF
-programs can be attached to the same device.
+For all HID-BPF attachment types except for :c:func:`hid_rdesc_fixup`, several eBPF
+programs can be attached to the same device. If a HID-BPF struct_ops has a
+:c:func:`hid_rdesc_fixup` while another is already attached to the device, the
+kernel will return `-EINVAL` when attaching the struct_ops.
Unless ``HID_BPF_FLAG_INSERT_HEAD`` is added to the flags while attaching the
program, the new program is appended at the end of the list.
@@ -234,8 +242,8 @@ from the device.
Note that if there are multiple programs using the ``HID_BPF_FLAG_INSERT_HEAD`` flag,
only the most recently loaded one is actually the first in the list.
-``SEC("fmod_ret/hid_bpf_device_event")``
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``SEC("struct_ops/hid_device_event")``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whenever a matching event is raised, the eBPF programs are called one after the other
and are working on the same data buffer.
@@ -258,17 +266,17 @@ with, userspace needs to refer to the device by its unique system id (the last 4
in the sysfs path: ``/sys/bus/hid/devices/xxxx:yyyy:zzzz:0000``).
To retrieve a context associated with the device, the program must call
-:c:func:`hid_bpf_allocate_context` and must release it with :c:func:`hid_bpf_release_context`
+hid_bpf_allocate_context() and must release it with hid_bpf_release_context()
before returning.
Once the context is retrieved, one can also request a pointer to kernel memory with
-:c:func:`hid_bpf_get_data`. This memory is big enough to support all input/output/feature
+hid_bpf_get_data(). This memory is big enough to support all input/output/feature
reports of the given device.
-``SEC("fmod_ret/hid_bpf_rdesc_fixup")``
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``SEC("struct_ops/hid_rdesc_fixup")``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The ``hid_bpf_rdesc_fixup`` program works in a similar manner to
-``.report_fixup`` of ``struct hid_driver``.
+The ``hid_rdesc_fixup`` program works in a similar manner to ``.report_fixup``
+of ``struct hid_driver``.
When the device is probed, the kernel sets the data buffer of the context with the
content of the report descriptor. The memory associated with that buffer is
@@ -277,33 +285,31 @@ content of the report descriptor. The memory associated with that buffer is
The eBPF program can modify the data buffer at-will and the kernel uses the
modified content and size as the report descriptor.
-Whenever a ``SEC("fmod_ret/hid_bpf_rdesc_fixup")`` program is attached (if no
-program was attached before), the kernel immediately disconnects the HID device
-and does a reprobe.
+Whenever a struct_ops containing a ``SEC("struct_ops/hid_rdesc_fixup")`` program
+is attached (if no program was attached before), the kernel immediately disconnects
+the HID device and does a reprobe.
-In the same way, when the ``SEC("fmod_ret/hid_bpf_rdesc_fixup")`` program is
-detached, the kernel issues a disconnect on the device.
+In the same way, when this struct_ops is detached, the kernel issues a disconnect
+on the device.
There is no ``detach`` facility in HID-BPF. Detaching a program happens when
-all the user space file descriptors pointing at a program are closed.
+all the user space file descriptors pointing at a HID-BPF struct_ops link are closed.
Thus, if we need to replace a report descriptor fixup, some cooperation is
required from the owner of the original report descriptor fixup.
-The previous owner will likely pin the program in the bpffs, and we can then
+The previous owner will likely pin the struct_ops link in the bpffs, and we can then
replace it through normal bpf operations.
Attaching a bpf program to a device
===================================
-``libbpf`` does not export any helper to attach a HID-BPF program.
-Users need to use a dedicated ``syscall`` program which will call
-``hid_bpf_attach_prog(hid_id, program_fd, flags)``.
+We now use standard struct_ops attachment through ``bpf_map__attach_struct_ops()``.
+But given that we need to attach a struct_ops to a dedicated HID device, the caller
+must set ``hid_id`` in the struct_ops map before loading the program in the kernel.
``hid_id`` is the unique system ID of the HID device (the last 4 numbers in the
sysfs path: ``/sys/bus/hid/devices/xxxx:yyyy:zzzz:0000``)
-``progam_fd`` is the opened file descriptor of the program to attach.
-
-``flags`` is of type ``enum hid_bpf_attach_flags``.
+One can also set ``flags``, which is of type ``enum hid_bpf_attach_flags``.
We can not rely on hidraw to bind a BPF program to a HID device. hidraw is an
artefact of the processing of the HID device, and is not stable. Some drivers
@@ -358,32 +364,15 @@ For that, we can create a basic skeleton for our BPF program::
extern __u8 *hid_bpf_get_data(struct hid_bpf_ctx *ctx,
unsigned int offset,
const size_t __sz) __ksym;
- extern int hid_bpf_attach_prog(unsigned int hid_id, int prog_fd, u32 flags) __ksym;
struct {
__uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, 4096 * 64);
} ringbuf SEC(".maps");
- struct attach_prog_args {
- int prog_fd;
- unsigned int hid;
- unsigned int flags;
- int retval;
- };
-
- SEC("syscall")
- int attach_prog(struct attach_prog_args *ctx)
- {
- ctx->retval = hid_bpf_attach_prog(ctx->hid,
- ctx->prog_fd,
- ctx->flags);
- return 0;
- }
-
__u8 current_value = 0;
- SEC("?fmod_ret/hid_bpf_device_event")
+ SEC("struct_ops/hid_device_event")
int BPF_PROG(filter_switch, struct hid_bpf_ctx *hid_ctx)
{
__u8 *data = hid_bpf_get_data(hid_ctx, 0 /* offset */, 192 /* size */);
@@ -407,37 +396,37 @@ For that, we can create a basic skeleton for our BPF program::
return 0;
}
-To attach ``filter_switch``, userspace needs to call the ``attach_prog`` syscall
-program first::
+ SEC(".struct_ops.link")
+ struct hid_bpf_ops haptic_tablet = {
+ .hid_device_event = (void *)filter_switch,
+ };
+
+
+To attach ``haptic_tablet``, userspace needs to set ``hid_id`` first::
static int attach_filter(struct hid *hid_skel, int hid_id)
{
- int err, prog_fd;
- int ret = -1;
- struct attach_prog_args args = {
- .hid = hid_id,
- };
- DECLARE_LIBBPF_OPTS(bpf_test_run_opts, tattrs,
- .ctx_in = &args,
- .ctx_size_in = sizeof(args),
- );
+ int err, link_fd;
- args.prog_fd = bpf_program__fd(hid_skel->progs.filter_switch);
+ hid_skel->struct_ops.haptic_tablet->hid_id = hid_id;
+ err = hid__load(skel);
+ if (err)
+ return err;
- prog_fd = bpf_program__fd(hid_skel->progs.attach_prog);
-
- err = bpf_prog_test_run_opts(prog_fd, &tattrs);
- if (err)
- return err;
+ link_fd = bpf_map__attach_struct_ops(hid_skel->maps.haptic_tablet);
+ if (!link_fd) {
+ fprintf(stderr, "can not attach HID-BPF program: %m\n");
+ return -1;
+ }
- return args.retval; /* the fd of the created bpf_link */
+ return link_fd; /* the fd of the created bpf_link */
}
Our userspace program can now listen to notifications on the ring buffer, and
is awaken only when the value changes.
When the userspace program doesn't need to listen to events anymore, it can just
-close the returned fd from :c:func:`attach_filter`, which will tell the kernel to
+close the returned bpf link from :c:func:`attach_filter`, which will tell the kernel to
detach the program from the HID device.
Of course, in other use cases, the userspace program can also pin the fd to the
diff --git a/include/linux/hid_bpf.h b/include/linux/hid_bpf.h
index c0682db73aeb..36cfaf092d0f 100644
--- a/include/linux/hid_bpf.h
+++ b/include/linux/hid_bpf.h
@@ -20,11 +20,9 @@ struct hid_device;
* struct hid_bpf_ctx - User accessible data for all HID programs
*
* ``data`` is not directly accessible from the context. We need to issue
- * a call to ``hid_bpf_get_data()`` in order to get a pointer to that field.
+ * a call to hid_bpf_get_data() in order to get a pointer to that field.
*
- * All of these fields are currently read-only.
- *
- * @hid: the ``struct hid_device`` representing the device itself
+ * @hid: the &struct hid_device representing the device itself
* @allocated_size: Allocated size of data.
*
* This is how much memory is available and can be requested
@@ -41,6 +39,8 @@ struct hid_device;
* ``size`` must always be less or equal than ``allocated_size`` (it is enforced
* once all BPF programs have been run).
* @retval: Return value of the previous program.
+ *
+ * ``hid`` and ``allocated_size`` are read-only, ``size`` and ``retval`` are read-write.
*/
struct hid_bpf_ctx {
const struct hid_device *hid;
--
2.44.0
^ permalink raw reply related
* [PATCH HID 11/13] Documentation: HID: add a small blurb on udev-hid-bpf
From: Benjamin Tissoires @ 2024-05-28 13:14 UTC (permalink / raw)
To: Shuah Khan, Jiri Kosina, Jonathan Corbet, Alexei Starovoitov
Cc: linux-kselftest, linux-kernel, bpf, linux-input, linux-doc,
Benjamin Tissoires
In-Reply-To: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@kernel.org>
This is the current decision we took: we don't provide automatic loading
of HID-BPF by the kernel directly, but rely on an external tool for it.
This tool is currently udev-hid-bpf, so let's make people aware of it.
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
Documentation/hid/hid-bpf.rst | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/Documentation/hid/hid-bpf.rst b/Documentation/hid/hid-bpf.rst
index bb8457bf15dd..7b151a2aef63 100644
--- a/Documentation/hid/hid-bpf.rst
+++ b/Documentation/hid/hid-bpf.rst
@@ -129,6 +129,23 @@ When a BPF program needs to emit input events, it needs to talk with the HID
protocol, and rely on the HID kernel processing to translate the HID data into
input events.
+In-tree HID-BPF programs and ``udev-hid-bpf``
+=============================================
+
+Official device fixes are shipped in the kernel tree as source in the
+``drivers/hid/bpf/progs`` directory. This allows to add selftests to them in
+``tools/testing/selftests/hid``.
+
+However, the compilation of these objects is not part of a regular kernel compilation
+given that they need an external tool to be loaded. This tool is currently
+`udev-hid-bpf <https://libevdev.pages.freedesktop.org/udev-hid-bpf/index.html>`_.
+
+For convenience, that external repository duplicates the files from here in
+``drivers/hid/bpf/progs`` into its own ``src/bpf/stable`` directory. This allows
+distributions to not have to pull the entire kernel source tree to ship and package
+those HID-BPF fixes. ``udev-hid-bpf`` also has capabilities of handling multiple
+objects files depending on the kernel the user is running.
+
Available types of programs
===========================
--
2.44.0
^ permalink raw reply related
* [PATCH HID 12/13] HID: bpf: Artist24: remove unused variable
From: Benjamin Tissoires @ 2024-05-28 13:14 UTC (permalink / raw)
To: Shuah Khan, Jiri Kosina, Jonathan Corbet, Alexei Starovoitov
Cc: linux-kselftest, linux-kernel, bpf, linux-input, linux-doc,
Benjamin Tissoires, Peter Hutterer
In-Reply-To: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@kernel.org>
warning: unused variable ‘tilt’ [-Wunused-variable]
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c b/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c
index bc0b85c38445..d4d062c3a653 100644
--- a/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c
+++ b/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c
@@ -158,7 +158,6 @@ int BPF_PROG(xppen_24_fix_eraser, struct hid_bpf_ctx *hctx)
__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 10 /* size */);
__u8 current_state, changed_state;
bool prev_tip;
- __u16 tilt;
if (!data)
return 0; /* EPERM check */
--
2.44.0
^ permalink raw reply related
* [PATCH HID 13/13] HID: bpf: error on warnings when compiling bpf objects
From: Benjamin Tissoires @ 2024-05-28 13:14 UTC (permalink / raw)
To: Shuah Khan, Jiri Kosina, Jonathan Corbet, Alexei Starovoitov
Cc: linux-kselftest, linux-kernel, bpf, linux-input, linux-doc,
Benjamin Tissoires
In-Reply-To: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@kernel.org>
There is no real reasons to paper over warnings for such small programs.
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
drivers/hid/bpf/progs/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid/bpf/progs/Makefile
index 63ed7e02adf1..ec1fc642fd63 100644
--- a/drivers/hid/bpf/progs/Makefile
+++ b/drivers/hid/bpf/progs/Makefile
@@ -56,7 +56,7 @@ clean:
%.bpf.o: %.bpf.c vmlinux.h $(BPFOBJ) | $(OUTPUT)
$(call msg,BPF,$@)
- $(Q)$(CLANG) -g -O2 --target=bpf $(INCLUDES) \
+ $(Q)$(CLANG) -g -O2 --target=bpf -Wall -Werror $(INCLUDES) \
-c $(filter %.c,$^) -o $@ && \
$(LLVM_STRIP) -g $@
--
2.44.0
^ permalink raw reply related
* Re: [PATCH v2 0/2] arm64: dts: allwinner: H616: Add LRADC
From: Chen-Yu Tsai @ 2024-05-28 15:42 UTC (permalink / raw)
To: Hans de Goede, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jernej Skrabec, Samuel Holland, Andre Przywara,
James McGregor
Cc: linux-input, devicetree, linux-arm-kernel, linux-sunxi
In-Reply-To: <20240426092924.15489-1-jamcgregor@protonmail.com>
On Fri, 26 Apr 2024 09:29:37 +0000, James McGregor wrote:
> Version 2 moves the LRADC DT node to the right place. It was out of
> order before.
>
> The Allwinner H616 series of SoCs have a low-rate ADC (LRADC) with
> 6-bit resolution and one input channel. They're compatible with the
> existing drivers, so it only needs to be enabled in the DT.
>
> [...]
Applied to sunxi/dt-for-6.11 in sunxi/linux.git, thanks!
[1/2] dt-bindings: input: sun4i-lradc-keys: Add H616 compatible
https://git.kernel.org/sunxi/linux/c/3086803a1f43
[2/2] ARM: dts: sun50i: Add LRADC node
https://git.kernel.org/sunxi/linux/c/7adc2d68f4a6
Best regards,
--
Chen-Yu Tsai <wens@csie.org>
^ permalink raw reply
* Re: [PATCH v2 0/2] arm64: dts: allwinner: H616: Add LRADC
From: Chen-Yu Tsai @ 2024-05-28 16:18 UTC (permalink / raw)
To: Samuel Holland, James McGregor, Jernej Skrabec
Cc: linux-input, devicetree, linux-arm-kernel, linux-sunxi,
Conor Dooley, Andre Przywara, Hans de Goede, Dmitry Torokhov,
Rob Herring, Krzysztof Kozlowski
In-Reply-To: <171691092979.680152.13758975851829859883.b4-ty@csie.org>
On Tue, May 28, 2024 at 11:42 PM Chen-Yu Tsai <wens@csie.org> wrote:
>
> On Fri, 26 Apr 2024 09:29:37 +0000, James McGregor wrote:
> > Version 2 moves the LRADC DT node to the right place. It was out of
> > order before.
> >
> > The Allwinner H616 series of SoCs have a low-rate ADC (LRADC) with
> > 6-bit resolution and one input channel. They're compatible with the
> > existing drivers, so it only needs to be enabled in the DT.
> >
> > [...]
>
> Applied to sunxi/dt-for-6.11 in sunxi/linux.git, thanks!
>
> [1/2] dt-bindings: input: sun4i-lradc-keys: Add H616 compatible
> https://git.kernel.org/sunxi/linux/c/3086803a1f43
> [2/2] ARM: dts: sun50i: Add LRADC node
> https://git.kernel.org/sunxi/linux/c/7adc2d68f4a6
I had to do a quick rebase as the branch start point was incorrect. The
commit hashes will have changed. Rest assured that the patch is indeed
merged.
ChenYu
^ permalink raw reply
* Re: [PATCH 1/2] input: Add event code for accessibility key
From: Dmitry Torokhov @ 2024-05-28 20:17 UTC (permalink / raw)
To: Aseda Aboagye; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input
In-Reply-To: <Zk7bbiOwF4ODEE6H@google.com>
On Thu, May 23, 2024 at 01:00:14AM -0500, Aseda Aboagye wrote:
> HUTRR116 added support for a new usage titled "System Accessibility
> Binding" which toggles a system-wide bound accessibility UI or command.
> This commit simply adds a new event code for the usage.
>
> Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
> ---
> drivers/hid/hid-debug.c | 1 +
> drivers/hid/hid-input.c | 3 +++
> include/uapi/linux/input-event-codes.h | 2 ++
> 3 files changed, 6 insertions(+)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index e7ef1ea107c9..7749c81b6227 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -974,6 +974,7 @@ static const char *keys[KEY_MAX + 1] = {
> [KEY_CAMERA_ACCESS_ENABLE] = "CameraAccessEnable",
> [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
> [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
> + [KEY_ACCESSIBILITY] = "Accessibility",
> [KEY_DICTATE] = "Dictate",
> [KEY_MICMUTE] = "MicrophoneMute",
> [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 851ee86eff32..6d2dbb75ba65 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -829,6 +829,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
> switch (usage->hid & 0xf) {
> case 0x9: map_key_clear(KEY_MICMUTE); break;
> + case 0xa:
> + map_key_clear(KEY_ACCESSIBILITY);
> + break;
Please keep the style to match with the rest of the file.
> default: goto ignore;
> }
> break;
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 022a520e31fc..980ef7fefd2b 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -617,6 +617,8 @@
> #define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */
> #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
> #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
> +/* Toggles the system bound accessibility UI/command (HUTRR116) */
> +#define KEY_ACCESSIBILITY 0x24e
Please have the comment after the value to match with the rest of the
file (even though it results in a long line).
>
> #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
> #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
>
> base-commit: 5128de84d8fc849400d00f7a6982711f129699ea
> --
> 2.45.1.288.g0e0cd299f1-goog
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH 2/2] input: Add support for "Do Not Disturb"
From: Dmitry Torokhov @ 2024-05-28 20:18 UTC (permalink / raw)
To: Aseda Aboagye; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input
In-Reply-To: <Zk7csk3RHEqCruWU@google.com>
On Thu, May 23, 2024 at 01:05:38AM -0500, Aseda Aboagye wrote:
> HUTRR94 added support for a new usage titled "System Do Not Disturb"
> which toggles a system-wide Do Not Disturb setting. This commit simply
> adds a new event code for the usage.
>
> Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
> ---
> drivers/hid/hid-debug.c | 1 +
> drivers/hid/hid-input.c | 11 +++++++++++
> include/uapi/linux/input-event-codes.h | 2 ++
> 3 files changed, 14 insertions(+)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index 7749c81b6227..78b2dd10cba2 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -975,6 +975,7 @@ static const char *keys[KEY_MAX + 1] = {
> [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
> [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
> [KEY_ACCESSIBILITY] = "Accessibility",
> + [KEY_DONOTDISTURB] = "DoNotDisturb",
> [KEY_DICTATE] = "Dictate",
> [KEY_MICMUTE] = "MicrophoneMute",
> [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 6d2dbb75ba65..7fda66f7b437 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -826,6 +826,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> break;
> }
>
> + if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/
> + switch (usage->hid & 0xf) {
> + case 0xb:
> + map_key_clear(KEY_DONOTDISTURB);
> + break;
> + default:
> + goto ignore;
> + }
> + break;
> + }
> +
> if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
> switch (usage->hid & 0xf) {
> case 0x9: map_key_clear(KEY_MICMUTE); break;
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 980ef7fefd2b..b8abc239d660 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -619,6 +619,8 @@
> #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
> /* Toggles the system bound accessibility UI/command (HUTRR116) */
> #define KEY_ACCESSIBILITY 0x24e
> +/* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/
> +#define KEY_DONOTDISTURB 0x24f
Could we have this as KEY_DO_NOT_DISTURB?
Also the same comments as on the previous patch.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH 2/2] HID: intel-ish-hid: fix endian-conversion
From: kernel test robot @ 2024-05-28 21:06 UTC (permalink / raw)
To: Arnd Bergmann, Srinivas Pandruvada, Jiri Kosina,
Benjamin Tissoires, Zhang Lixu
Cc: oe-kbuild-all, Arnd Bergmann, linux-input, linux-kernel
In-Reply-To: <20240528115802.3122955-2-arnd@kernel.org>
Hi Arnd,
kernel test robot noticed the following build errors:
[auto build test ERROR on hid/for-next]
[also build test ERROR on next-20240528]
[cannot apply to linus/master v6.10-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Arnd-Bergmann/HID-intel-ish-hid-fix-endian-conversion/20240528-200100
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
patch link: https://lore.kernel.org/r/20240528115802.3122955-2-arnd%40kernel.org
patch subject: [PATCH 2/2] HID: intel-ish-hid: fix endian-conversion
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20240529/202405290420.DtwUdg3b-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240529/202405290420.DtwUdg3b-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405290420.DtwUdg3b-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/hid/intel-ish-hid/ishtp/loader.c: In function 'prepare_dma_bufs':
>> drivers/hid/intel-ish-hid/ishtp/loader.c:178:51: error: 'dma' undeclared (first use in this function); did you mean 'cma'?
178 | &dma, GFP_KERNEL);
| ^~~
| cma
drivers/hid/intel-ish-hid/ishtp/loader.c:178:51: note: each undeclared identifier is reported only once for each function it appears in
vim +178 drivers/hid/intel-ish-hid/ishtp/loader.c
154
155 /**
156 * prepare_dma_bufs() - Prepare the DMA buffer for transferring firmware fragments
157 * @dev: The ISHTP device
158 * @ish_fw: The ISH firmware
159 * @fragment: The ISHTP firmware fragment descriptor
160 * @dma_bufs: The array of DMA fragment buffers
161 * @fragment_size: The size of a single DMA fragment
162 *
163 * Return: 0 on success, negative error code on failure
164 */
165 static int prepare_dma_bufs(struct ishtp_device *dev,
166 const struct firmware *ish_fw,
167 struct loader_xfer_dma_fragment *fragment,
168 void **dma_bufs, u32 fragment_size, u32 fragment_count)
169 {
170 dma_addr_t dma_addr;
171 u32 offset = 0;
172 u32 length;
173 int i;
174
175 for (i = 0; i < fragment->fragment_cnt && offset < ish_fw->size; i++) {
176 dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size, &dma_addr, GFP_KERNEL);
177 dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size,
> 178 &dma, GFP_KERNEL);
179 if (!dma_bufs[i])
180 return -ENOMEM;
181
182 fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);
183
184 memcpy(dma_bufs[i], ish_fw->data + offset, le32_to_cpu(fragment->fragment_tbl[i].length));
185 dma_wmb();
186 fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma);
187 length = clamp(ish_fw->size - offset, 0, fragment_size);
188 fragment->fragment_tbl[i].length = cpu_to_le32(length);
189 fragment->fragment_tbl[i].fw_off = cpu_to_le32(offset);
190
191 offset += length;
192 }
193
194 return 0;
195 }
196
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply
* Re: [PATCH 2/2] HID: intel-ish-hid: fix endian-conversion
From: kernel test robot @ 2024-05-28 21:17 UTC (permalink / raw)
To: Arnd Bergmann, Srinivas Pandruvada, Jiri Kosina,
Benjamin Tissoires, Zhang Lixu
Cc: llvm, oe-kbuild-all, Arnd Bergmann, linux-input, linux-kernel
In-Reply-To: <20240528115802.3122955-2-arnd@kernel.org>
Hi Arnd,
kernel test robot noticed the following build errors:
[auto build test ERROR on hid/for-next]
[also build test ERROR on next-20240528]
[cannot apply to linus/master v6.10-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Arnd-Bergmann/HID-intel-ish-hid-fix-endian-conversion/20240528-200100
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
patch link: https://lore.kernel.org/r/20240528115802.3122955-2-arnd%40kernel.org
patch subject: [PATCH 2/2] HID: intel-ish-hid: fix endian-conversion
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20240529/202405290447.n14W21hZ-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240529/202405290447.n14W21hZ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405290447.n14W21hZ-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/hid/intel-ish-hid/ishtp/loader.c:178:9: error: use of undeclared identifier 'dma'
178 | &dma, GFP_KERNEL);
| ^
drivers/hid/intel-ish-hid/ishtp/loader.c:186:52: error: use of undeclared identifier 'dma'
186 | fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma);
| ^
include/linux/byteorder/generic.h:86:21: note: expanded from macro 'cpu_to_le64'
86 | #define cpu_to_le64 __cpu_to_le64
| ^
2 errors generated.
vim +/dma +178 drivers/hid/intel-ish-hid/ishtp/loader.c
154
155 /**
156 * prepare_dma_bufs() - Prepare the DMA buffer for transferring firmware fragments
157 * @dev: The ISHTP device
158 * @ish_fw: The ISH firmware
159 * @fragment: The ISHTP firmware fragment descriptor
160 * @dma_bufs: The array of DMA fragment buffers
161 * @fragment_size: The size of a single DMA fragment
162 *
163 * Return: 0 on success, negative error code on failure
164 */
165 static int prepare_dma_bufs(struct ishtp_device *dev,
166 const struct firmware *ish_fw,
167 struct loader_xfer_dma_fragment *fragment,
168 void **dma_bufs, u32 fragment_size, u32 fragment_count)
169 {
170 dma_addr_t dma_addr;
171 u32 offset = 0;
172 u32 length;
173 int i;
174
175 for (i = 0; i < fragment->fragment_cnt && offset < ish_fw->size; i++) {
176 dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size, &dma_addr, GFP_KERNEL);
177 dma_bufs[i] = dma_alloc_coherent(dev->devc, fragment_size,
> 178 &dma, GFP_KERNEL);
179 if (!dma_bufs[i])
180 return -ENOMEM;
181
182 fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma_addr);
183
184 memcpy(dma_bufs[i], ish_fw->data + offset, le32_to_cpu(fragment->fragment_tbl[i].length));
185 dma_wmb();
186 fragment->fragment_tbl[i].ddr_adrs = cpu_to_le64(dma);
187 length = clamp(ish_fw->size - offset, 0, fragment_size);
188 fragment->fragment_tbl[i].length = cpu_to_le32(length);
189 fragment->fragment_tbl[i].fw_off = cpu_to_le32(offset);
190
191 offset += length;
192 }
193
194 return 0;
195 }
196
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply
* [PATCH v2 1/2] input: Add event code for accessibility key
From: Aseda Aboagye @ 2024-05-28 22:44 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Dmitry Torokhov, linux-input
HUTRR116 added support for a new usage titled "System Accessibility
Binding" which toggles a system-wide bound accessibility UI or command.
This commit simply adds a new event code for the usage.
Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
---
Changes from v1:
- Modified formatting to match existing code, ignoring checkpatch.pl.
drivers/hid/hid-debug.c | 1 +
drivers/hid/hid-input.c | 1 +
include/uapi/linux/input-event-codes.h | 1 +
3 files changed, 3 insertions(+)
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index e7ef1ea107c9..7749c81b6227 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -974,6 +974,7 @@ static const char *keys[KEY_MAX + 1] = {
[KEY_CAMERA_ACCESS_ENABLE] = "CameraAccessEnable",
[KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
[KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
+ [KEY_ACCESSIBILITY] = "Accessibility",
[KEY_DICTATE] = "Dictate",
[KEY_MICMUTE] = "MicrophoneMute",
[KEY_BRIGHTNESS_MIN] = "BrightnessMin",
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 851ee86eff32..1ecc5ad57b56 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -829,6 +829,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
switch (usage->hid & 0xf) {
case 0x9: map_key_clear(KEY_MICMUTE); break;
+ case 0xa: map_key_clear(KEY_ACCESSIBILITY); break;
default: goto ignore;
}
break;
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 022a520e31fc..7ff6eeef1af0 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -617,6 +617,7 @@
#define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */
#define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
#define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
+#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */
#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
base-commit: 5128de84d8fc849400d00f7a6982711f129699ea
--
2.45.1.288.g0e0cd299f1-goog
^ permalink raw reply related
* [PATCH v2 2/2] input: Add support for "Do Not Disturb"
From: Aseda Aboagye @ 2024-05-28 22:51 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Dmitry Torokhov, linux-input
In-Reply-To: <ZlZeMVHsquYbQzGG@google.com>
HUTRR94 added support for a new usage titled "System Do Not Disturb"
which toggles a system-wide Do Not Disturb setting. This commit simply
adds a new event code for the usage.
Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
---
Changes from v1:
- Modified formatting to match existing code, ignoring checkpatch.pl.
drivers/hid/hid-debug.c | 1 +
drivers/hid/hid-input.c | 8 ++++++++
include/uapi/linux/input-event-codes.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 7749c81b6227..78b2dd10cba2 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -975,6 +975,7 @@ static const char *keys[KEY_MAX + 1] = {
[KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
[KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
[KEY_ACCESSIBILITY] = "Accessibility",
+ [KEY_DONOTDISTURB] = "DoNotDisturb",
[KEY_DICTATE] = "Dictate",
[KEY_MICMUTE] = "MicrophoneMute",
[KEY_BRIGHTNESS_MIN] = "BrightnessMin",
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 1ecc5ad57b56..f023f51b9c08 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -826,6 +826,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
break;
}
+ if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/
+ switch (usage->hid & 0xf) {
+ case 0xb: map_key_clear(KEY_DONOTDISTURB); break;
+ default: goto ignore;
+ }
+ break;
+ }
+
if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
switch (usage->hid & 0xf) {
case 0x9: map_key_clear(KEY_MICMUTE); break;
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 7ff6eeef1af0..c971d542e525 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -618,6 +618,7 @@
#define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
#define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */
+#define KEY_DONOTDISTURB 0x24f /* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/
#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
--
2.45.1.288.g0e0cd299f1-goog
^ permalink raw reply related
* Re: [PATCH v2 1/2] input: Add event code for accessibility key
From: Dmitry Torokhov @ 2024-05-28 23:31 UTC (permalink / raw)
To: Aseda Aboagye; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input
In-Reply-To: <ZlZeMVHsquYbQzGG@google.com>
On Tue, May 28, 2024 at 05:44:01PM -0500, Aseda Aboagye wrote:
> HUTRR116 added support for a new usage titled "System Accessibility
> Binding" which toggles a system-wide bound accessibility UI or command.
> This commit simply adds a new event code for the usage.
>
> Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
> ---
> Changes from v1:
> - Modified formatting to match existing code, ignoring checkpatch.pl.
>
> drivers/hid/hid-debug.c | 1 +
> drivers/hid/hid-input.c | 1 +
> include/uapi/linux/input-event-codes.h | 1 +
> 3 files changed, 3 insertions(+)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index e7ef1ea107c9..7749c81b6227 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -974,6 +974,7 @@ static const char *keys[KEY_MAX + 1] = {
> [KEY_CAMERA_ACCESS_ENABLE] = "CameraAccessEnable",
> [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
> [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
> + [KEY_ACCESSIBILITY] = "Accessibility",
> [KEY_DICTATE] = "Dictate",
> [KEY_MICMUTE] = "MicrophoneMute",
> [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 851ee86eff32..1ecc5ad57b56 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -829,6 +829,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
> switch (usage->hid & 0xf) {
> case 0x9: map_key_clear(KEY_MICMUTE); break;
> + case 0xa: map_key_clear(KEY_ACCESSIBILITY); break;
> default: goto ignore;
> }
> break;
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 022a520e31fc..7ff6eeef1af0 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -617,6 +617,7 @@
> #define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */
> #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
> #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
> +#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */
For input:
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Feel free to merge through HID tree.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 2/2] input: Add support for "Do Not Disturb"
From: Dmitry Torokhov @ 2024-05-28 23:32 UTC (permalink / raw)
To: Aseda Aboagye; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input
In-Reply-To: <ZlZgByQ3TlycC-A_@google.com>
On Tue, May 28, 2024 at 05:51:51PM -0500, Aseda Aboagye wrote:
> HUTRR94 added support for a new usage titled "System Do Not Disturb"
> which toggles a system-wide Do Not Disturb setting. This commit simply
> adds a new event code for the usage.
>
> Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
> ---
> Changes from v1:
> - Modified formatting to match existing code, ignoring checkpatch.pl.
>
> drivers/hid/hid-debug.c | 1 +
> drivers/hid/hid-input.c | 8 ++++++++
> include/uapi/linux/input-event-codes.h | 1 +
> 3 files changed, 10 insertions(+)
>
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> index 7749c81b6227..78b2dd10cba2 100644
> --- a/drivers/hid/hid-debug.c
> +++ b/drivers/hid/hid-debug.c
> @@ -975,6 +975,7 @@ static const char *keys[KEY_MAX + 1] = {
> [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
> [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
> [KEY_ACCESSIBILITY] = "Accessibility",
> + [KEY_DONOTDISTURB] = "DoNotDisturb",
> [KEY_DICTATE] = "Dictate",
> [KEY_MICMUTE] = "MicrophoneMute",
> [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 1ecc5ad57b56..f023f51b9c08 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -826,6 +826,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> break;
> }
>
> + if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/
> + switch (usage->hid & 0xf) {
> + case 0xb: map_key_clear(KEY_DONOTDISTURB); break;
> + default: goto ignore;
> + }
> + break;
> + }
> +
> if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
> switch (usage->hid & 0xf) {
> case 0x9: map_key_clear(KEY_MICMUTE); break;
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 7ff6eeef1af0..c971d542e525 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -618,6 +618,7 @@
> #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
> #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
> #define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */
> +#define KEY_DONOTDISTURB 0x24f /* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/
Please spare a few underscores: KEY_DO_NOT_DISTURB.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v2 2/2] input: Add support for "Do Not Disturb"
From: Aseda Aboagye @ 2024-05-29 0:06 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input
In-Reply-To: <ZlZpkrUuBonHDPaj@google.com>
On Tue, May 28, 2024 at 04:32:34PM -0700, Dmitry Torokhov wrote:
> On Tue, May 28, 2024 at 05:51:51PM -0500, Aseda Aboagye wrote:
> > HUTRR94 added support for a new usage titled "System Do Not Disturb"
> > which toggles a system-wide Do Not Disturb setting. This commit simply
> > adds a new event code for the usage.
> >
> > Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
> > ---
> > Changes from v1:
> > - Modified formatting to match existing code, ignoring checkpatch.pl.
> >
> > drivers/hid/hid-debug.c | 1 +
> > drivers/hid/hid-input.c | 8 ++++++++
> > include/uapi/linux/input-event-codes.h | 1 +
> > 3 files changed, 10 insertions(+)
> >
> > diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> > index 7749c81b6227..78b2dd10cba2 100644
> > --- a/drivers/hid/hid-debug.c
> > +++ b/drivers/hid/hid-debug.c
> > @@ -975,6 +975,7 @@ static const char *keys[KEY_MAX + 1] = {
> > [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
> > [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
> > [KEY_ACCESSIBILITY] = "Accessibility",
> > + [KEY_DONOTDISTURB] = "DoNotDisturb",
> > [KEY_DICTATE] = "Dictate",
> > [KEY_MICMUTE] = "MicrophoneMute",
> > [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> > index 1ecc5ad57b56..f023f51b9c08 100644
> > --- a/drivers/hid/hid-input.c
> > +++ b/drivers/hid/hid-input.c
> > @@ -826,6 +826,14 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> > break;
> > }
> >
> > + if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/
> > + switch (usage->hid & 0xf) {
> > + case 0xb: map_key_clear(KEY_DONOTDISTURB); break;
> > + default: goto ignore;
> > + }
> > + break;
> > + }
> > +
> > if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
> > switch (usage->hid & 0xf) {
> > case 0x9: map_key_clear(KEY_MICMUTE); break;
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index 7ff6eeef1af0..c971d542e525 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -618,6 +618,7 @@
> > #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
> > #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
> > #define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */
> > +#define KEY_DONOTDISTURB 0x24f /* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/
>
> Please spare a few underscores: KEY_DO_NOT_DISTURB.
>
My apologies, I didn't see your reply on v1 before I sent this. I will
address this in the next version.
>
> --
> Dmitry
--
Aseda Aboagye
^ permalink raw reply
* Re: [PATCH v2 1/2] input: Add event code for accessibility key
From: Aseda Aboagye @ 2024-05-29 0:08 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input
In-Reply-To: <ZlZpN9ohRY-Qx7E4@google.com>
On Tue, May 28, 2024 at 04:31:03PM -0700, Dmitry Torokhov wrote:
> On Tue, May 28, 2024 at 05:44:01PM -0500, Aseda Aboagye wrote:
> > HUTRR116 added support for a new usage titled "System Accessibility
> > Binding" which toggles a system-wide bound accessibility UI or command.
> > This commit simply adds a new event code for the usage.
> >
> > Signed-off-by: Aseda Aboagye <aaboagye@chromium.org>
> > ---
> > Changes from v1:
> > - Modified formatting to match existing code, ignoring checkpatch.pl.
> >
> > drivers/hid/hid-debug.c | 1 +
> > drivers/hid/hid-input.c | 1 +
> > include/uapi/linux/input-event-codes.h | 1 +
> > 3 files changed, 3 insertions(+)
> >
> > diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
> > index e7ef1ea107c9..7749c81b6227 100644
> > --- a/drivers/hid/hid-debug.c
> > +++ b/drivers/hid/hid-debug.c
> > @@ -974,6 +974,7 @@ static const char *keys[KEY_MAX + 1] = {
> > [KEY_CAMERA_ACCESS_ENABLE] = "CameraAccessEnable",
> > [KEY_CAMERA_ACCESS_DISABLE] = "CameraAccessDisable",
> > [KEY_CAMERA_ACCESS_TOGGLE] = "CameraAccessToggle",
> > + [KEY_ACCESSIBILITY] = "Accessibility",
> > [KEY_DICTATE] = "Dictate",
> > [KEY_MICMUTE] = "MicrophoneMute",
> > [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
> > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> > index 851ee86eff32..1ecc5ad57b56 100644
> > --- a/drivers/hid/hid-input.c
> > +++ b/drivers/hid/hid-input.c
> > @@ -829,6 +829,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
> > if ((usage->hid & 0xf0) == 0xa0) { /* SystemControl */
> > switch (usage->hid & 0xf) {
> > case 0x9: map_key_clear(KEY_MICMUTE); break;
> > + case 0xa: map_key_clear(KEY_ACCESSIBILITY); break;
> > default: goto ignore;
> > }
> > break;
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index 022a520e31fc..7ff6eeef1af0 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -617,6 +617,7 @@
> > #define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */
> > #define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
> > #define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
> > +#define KEY_ACCESSIBILITY 0x24e /* Toggles the system bound accessibility UI/command (HUTRR116) */
>
> For input:
>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Feel free to merge through HID tree.
>
Thank you so much for the review, I really appreciate it!
> Thanks.
>
> --
> Dmitry
--
Aseda Aboagye
^ permalink raw reply
* Re: [PATCH] hid-asus: use hid for brightness control on keyboard
From: Luke Jones @ 2024-05-29 0:37 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Jiri Kosina, Hans de Goede, corentin.chary, platform-driver-x86,
LKML, linux-input, bentiss
In-Reply-To: <17aa68e2-4af6-68ad-e81a-abc714517f6b@linux.intel.com>
On Tue, 28 May 2024, at 8:36 PM, Ilpo Järvinen wrote:
> On Tue, 28 May 2024, Luke D. Jones wrote:
>
> > On almost all ASUS ROG series laptops the MCU used for the USB keyboard
> > also has a HID packet used for setting the brightness. This is usually
> > the same as the WMI method. But in some laptops the WMI method either
> > is missing or doesn't work, so we should default to the HID control.
> >
> > Signed-off-by: Luke D. Jones <luke@ljones.dev>
> > ---
> > drivers/hid/hid-asus.c | 19 ++++++++++++-
> > drivers/platform/x86/asus-wmi.c | 3 ++-
> > include/linux/platform_data/x86/asus-wmi.h | 31 ++++++++++++++++++++++
> > 3 files changed, 51 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> > index 02de2bf4f790..9389a3e733e3 100644
> > --- a/drivers/hid/hid-asus.c
> > +++ b/drivers/hid/hid-asus.c
> > @@ -101,6 +101,7 @@ struct asus_kbd_leds {
> > unsigned int brightness;
> > spinlock_t lock;
> > bool removed;
> > + int report_id;
> > };
> >
> > struct asus_touchpad_info {
> > @@ -473,7 +474,7 @@ static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
> > static void asus_kbd_backlight_work(struct work_struct *work)
> > {
> > struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
> > - u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
> > + u8 buf[] = { led->report_id, 0xba, 0xc5, 0xc4, 0x00 };
> > int ret;
> > unsigned long flags;
> >
> > @@ -492,12 +493,18 @@ static void asus_kbd_backlight_work(struct work_struct *work)
> > */
> > static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
> > {
> > + struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> > u32 value;
> > int ret;
> >
> > if (!IS_ENABLED(CONFIG_ASUS_WMI))
> > return false;
> >
> > + if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_use_hidraw_led()) {
> > + hid_info(hdev, "using hidraw for asus::kbd_backlight\n");
> > + return false;
> > + }
> > +
> > ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
> > ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
> > hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
> > @@ -507,6 +514,12 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
> > return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
> > }
> >
> > +static bool asus_kbd_is_input_led(void)
> > +{
> > + return dmi_match(DMI_PRODUCT_NAME, "GU605")
> > + || dmi_match(DMI_PRODUCT_NAME, "GA403");
> > +}
> > +
> > static int asus_kbd_register_leds(struct hid_device *hdev)
> > {
> > struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> > @@ -549,6 +562,10 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
> > if (!drvdata->kbd_backlight)
> > return -ENOMEM;
> >
> > + drvdata->kbd_backlight->report_id = FEATURE_KBD_REPORT_ID;
> > + if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_kbd_is_input_led())
> > + drvdata->kbd_backlight->report_id = FEATURE_KBD_LED_REPORT_ID1;
> > +
> > drvdata->kbd_backlight->removed = false;
> > drvdata->kbd_backlight->brightness = 0;
> > drvdata->kbd_backlight->hdev = hdev;
> > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> > index 3f9b6285c9a6..a58df18a70ad 100644
> > --- a/drivers/platform/x86/asus-wmi.c
> > +++ b/drivers/platform/x86/asus-wmi.c
> > @@ -1681,7 +1681,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
> > goto error;
> > }
> >
> > - if (!kbd_led_read(asus, &led_val, NULL)) {
> > + if (!kbd_led_read(asus, &led_val, NULL) && !asus_use_hidraw_led()) {
> > + pr_info("using asus-wmi for asus::kbd_backlight\n");
> > asus->kbd_led_wk = led_val;
> > asus->kbd_led.name = "asus::kbd_backlight";
> > asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED;
> > diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
> > index 3eb5cd6773ad..79a50102440d 100644
> > --- a/include/linux/platform_data/x86/asus-wmi.h
> > +++ b/include/linux/platform_data/x86/asus-wmi.h
> > @@ -160,4 +160,35 @@ static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
> > }
> > #endif
> >
> > +/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
> > +#if IS_REACHABLE(CONFIG_ASUS_WMI)
> > +static bool asus_use_hidraw_led(void)
>
> Since it's in a header, it's missing inline. However, this function looks
> quite complicated so putting it into a header file is questionable to
> begin with so I'd prefer it to be in a .c file.
Thanks for the review y'all. All recommendations implemented including this and splitting to two commits.
> > +{
> > + const char *product, *board;
> > +
> > + product = dmi_get_system_info(DMI_PRODUCT_FAMILY);
> > + if (!product)
> > + return false;
> > +
> > + /* These product ranges should all be using HID for keyboard LED */
> > + if (strstr(product, "ROG Zephyrus")
> > + || strstr(product, "ROG Strix")
> > + || strstr(product, "ROG Flow")
> > + || strstr(product, "GA403")
> > + || strstr(product, "GU605"))
>
> Please align these properly but consider using array and loop.
>
> > + return true;
> > +
> > + board = dmi_get_system_info(DMI_BOARD_NAME);
> > + if (!board)
> > + return false;
> > +
> > + return strstr(board, "RC71L"); /* ROG Ally specific */
> > +}
> > +#else
> > +static inline bool asus_use_hidraw_led(void)
> > +{
> > + return true;
> > +}
> > +#endif
> > +
> > #endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */
> >
>
> --
> i.
>
>
^ permalink raw reply
* Re: [PATCH] Adding quirks for 2024 HP Spectre x360 touchpads
From: Jon Moeller @ 2024-05-28 18:21 UTC (permalink / raw)
To: Jon Moeller; +Cc: linux-input
In-Reply-To: <20240429070950.247183-1-jon@moeller.io>
Is there anything special I need to do to get this merged? I was
hoping this would get worked into 6.10.
On Mon, Apr 29, 2024 at 12:09 AM Jon Moeller <jon@moeller.io> wrote:
>
> ---
> drivers/hid/hid-multitouch.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index 04a014cd2a2f..7a7918191628 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -212,6 +212,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
> #define MT_CLS_GOOGLE 0x0111
> #define MT_CLS_RAZER_BLADE_STEALTH 0x0112
> #define MT_CLS_SMART_TECH 0x0113
> +#define MT_CLS_HP_SPECTRE_ELAN_HAPTIC 0x0114
>
> #define MT_DEFAULT_MAXCONTACT 10
> #define MT_MAX_MAXCONTACT 250
> @@ -396,6 +397,13 @@ static const struct mt_class mt_classes[] = {
> MT_QUIRK_CONTACT_CNT_ACCURATE |
> MT_QUIRK_SEPARATE_APP_REPORT,
> },
> + { .name = MT_CLS_HP_SPECTRE_ELAN_HAPTIC,
> + .quirks = MT_QUIRK_ALWAYS_VALID |
> + MT_QUIRK_SLOT_IS_CONTACTID |
> + MT_QUIRK_CONTACT_CNT_ACCURATE |
> + MT_QUIRK_CONFIDENCE |
> + MT_QUIRK_WIN8_PTP_BUTTONS,
> + },
> { }
> };
>
> @@ -1992,6 +2000,12 @@ static const struct hid_device_id mt_devices[] = {
> HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
> USB_VENDOR_ID_ELAN, 0x3148) },
>
> + { .driver_data = MT_CLS_HP_SPECTRE_ELAN_HAPTIC,
> + HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x32c8) },
> +
> + { .driver_data = MT_CLS_HP_SPECTRE_ELAN_HAPTIC,
> + HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x310a) },
> +
> /* Elitegroup panel */
> { .driver_data = MT_CLS_SERIAL,
> MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP,
> --
> 2.44.0
>
> Signed-off-by: Jon Moeller <jon@moeller.io>
^ permalink raw reply
* [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard
From: Luke D. Jones @ 2024-05-29 1:24 UTC (permalink / raw)
To: jikos
Cc: hdegoede, ilpo.jarvinen, corentin.chary, platform-driver-x86,
linux-kernel, linux-input, bentiss, Luke D. Jones
On almost all ASUS ROG series laptops the MCU used for the USB keyboard
also has a HID packet used for setting the brightness. This is usually
the same as the WMI method. But in some laptops the WMI method either
is missing or doesn't work, so we should default to the HID control.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/hid/hid-asus.c | 6 ++++
drivers/platform/x86/asus-wmi.c | 35 +++++++++++++++++++++-
include/linux/platform_data/x86/asus-wmi.h | 10 +++++++
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 02de2bf4f790..4cba8e143031 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -492,12 +492,18 @@ static void asus_kbd_backlight_work(struct work_struct *work)
*/
static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
{
+ struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
u32 value;
int ret;
if (!IS_ENABLED(CONFIG_ASUS_WMI))
return false;
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_use_hid_led()) {
+ hid_info(hdev, "using HID for asus::kbd_backlight\n");
+ return false;
+ }
+
ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f9b6285c9a6..54cb07c79fcf 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -144,6 +144,15 @@ module_param(fnlock_default, bool, 0444);
static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
+static const char * const use_hid_led_matches[] = {
+ "ROG Zephyrus",
+ "ROG Strix",
+ "ROG Flow",
+ "GA403",
+ "GU605",
+ "RC71L",
+};
+
static int throttle_thermal_policy_write(struct asus_wmi *);
static bool ashs_present(void)
@@ -1642,6 +1651,29 @@ static int micmute_led_set(struct led_classdev *led_cdev,
return err < 0 ? err : 0;
}
+bool asus_use_hid_led(void)
+{
+ const char *product, *board;
+ int i;
+
+ product = dmi_get_system_info(DMI_PRODUCT_FAMILY);
+ if (!product)
+ return false;
+
+ board = dmi_get_system_info(DMI_BOARD_NAME);
+ if (!board)
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(use_hid_led_matches); i++) {
+ if (strstr(product, use_hid_led_matches[i]))
+ return true;
+ if (strstr(board, use_hid_led_matches[i]))
+ return true;
+ }
+ return false;
+}
+EXPORT_SYMBOL_GPL(asus_use_hid_led);
+
static void asus_wmi_led_exit(struct asus_wmi *asus)
{
led_classdev_unregister(&asus->kbd_led);
@@ -1681,7 +1713,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
goto error;
}
- if (!kbd_led_read(asus, &led_val, NULL)) {
+ if (!kbd_led_read(asus, &led_val, NULL) && !asus_use_hid_led()) {
+ pr_info("using asus-wmi for asus::kbd_backlight\n");
asus->kbd_led_wk = led_val;
asus->kbd_led.name = "asus::kbd_backlight";
asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 3eb5cd6773ad..6833035f7006 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -160,4 +160,14 @@ static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
}
#endif
+/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
+#if IS_ENABLED(CONFIG_ASUS_WMI)
+bool asus_use_hid_led(void);
+#else
+static inline bool asus_use_hid_led(void)
+{
+ return true;
+}
+#endif
+
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */
--
2.45.1
^ permalink raw reply related
* [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control
From: Luke D. Jones @ 2024-05-29 1:24 UTC (permalink / raw)
To: jikos
Cc: hdegoede, ilpo.jarvinen, corentin.chary, platform-driver-x86,
linux-kernel, linux-input, bentiss, Luke D. Jones
In-Reply-To: <20240529012447.145088-1-luke@ljones.dev>
On some laptops the report_id used for LED brightness control must be
0x5D instead of 0x5A.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/hid/hid-asus.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 4cba8e143031..ec3556cc4eef 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -94,6 +94,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
#define TRKID_SGN ((TRKID_MAX + 1) >> 1)
+static const char * const use_alt_led_report_id[] = { "GU605", "GA403" };
+
struct asus_kbd_leds {
struct led_classdev cdev;
struct hid_device *hdev;
@@ -101,6 +103,7 @@ struct asus_kbd_leds {
unsigned int brightness;
spinlock_t lock;
bool removed;
+ int report_id;
};
struct asus_touchpad_info {
@@ -473,7 +476,7 @@ static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
static void asus_kbd_backlight_work(struct work_struct *work)
{
struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
- u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
+ u8 buf[] = { led->report_id, 0xba, 0xc5, 0xc4, 0x00 };
int ret;
unsigned long flags;
@@ -513,6 +516,23 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
}
+static bool asus_kbd_is_input_led(void)
+{
+ const char *product;
+ int i;
+
+ product = dmi_get_system_info(DMI_PRODUCT_NAME);
+ if (!product)
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(use_alt_led_report_id); i++) {
+ if (strstr(product, use_alt_led_report_id[i]))
+ return true;
+ }
+
+ return false;
+}
+
static int asus_kbd_register_leds(struct hid_device *hdev)
{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -555,6 +575,10 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
if (!drvdata->kbd_backlight)
return -ENOMEM;
+ drvdata->kbd_backlight->report_id = FEATURE_KBD_REPORT_ID;
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_kbd_is_input_led())
+ drvdata->kbd_backlight->report_id = FEATURE_KBD_LED_REPORT_ID1;
+
drvdata->kbd_backlight->removed = false;
drvdata->kbd_backlight->brightness = 0;
drvdata->kbd_backlight->hdev = hdev;
--
2.45.1
^ permalink raw reply related
* [PATCH v1 0/2] asus wmi and hid: use HID LED for brightness
From: Luke D. Jones @ 2024-05-29 1:28 UTC (permalink / raw)
To: jikos
Cc: hdegoede, ilpo.jarvinen, corentin.chary, platform-driver-x86,
linux-kernel, linux-input, bentiss, Luke D. Jones
Changelog:
- v1
- Split the patch in two
- Move function body to asus-wmi and export
- Use array of names and for loops
History:
- https://lore.kernel.org/linux-input/20240528013959.14661-1-luke@ljones.dev/T/#u
Luke D. Jones (2):
hid-asus: use hid for brightness control on keyboard
hid-asus: change the report_id used for HID LED control
drivers/hid/hid-asus.c | 32 +++++++++++++++++++-
drivers/platform/x86/asus-wmi.c | 35 +++++++++++++++++++++-
include/linux/platform_data/x86/asus-wmi.h | 10 +++++++
3 files changed, 75 insertions(+), 2 deletions(-)
--
2.45.1
^ permalink raw reply
* [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard
From: Luke D. Jones @ 2024-05-29 1:28 UTC (permalink / raw)
To: jikos
Cc: hdegoede, ilpo.jarvinen, corentin.chary, platform-driver-x86,
linux-kernel, linux-input, bentiss, Luke D. Jones
In-Reply-To: <20240529012827.146005-1-luke@ljones.dev>
On almost all ASUS ROG series laptops the MCU used for the USB keyboard
also has a HID packet used for setting the brightness. This is usually
the same as the WMI method. But in some laptops the WMI method either
is missing or doesn't work, so we should default to the HID control.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/hid/hid-asus.c | 6 ++++
drivers/platform/x86/asus-wmi.c | 35 +++++++++++++++++++++-
include/linux/platform_data/x86/asus-wmi.h | 10 +++++++
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 02de2bf4f790..4cba8e143031 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -492,12 +492,18 @@ static void asus_kbd_backlight_work(struct work_struct *work)
*/
static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
{
+ struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
u32 value;
int ret;
if (!IS_ENABLED(CONFIG_ASUS_WMI))
return false;
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_use_hid_led()) {
+ hid_info(hdev, "using HID for asus::kbd_backlight\n");
+ return false;
+ }
+
ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f9b6285c9a6..54cb07c79fcf 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -144,6 +144,15 @@ module_param(fnlock_default, bool, 0444);
static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
+static const char * const use_hid_led_matches[] = {
+ "ROG Zephyrus",
+ "ROG Strix",
+ "ROG Flow",
+ "GA403",
+ "GU605",
+ "RC71L",
+};
+
static int throttle_thermal_policy_write(struct asus_wmi *);
static bool ashs_present(void)
@@ -1642,6 +1651,29 @@ static int micmute_led_set(struct led_classdev *led_cdev,
return err < 0 ? err : 0;
}
+bool asus_use_hid_led(void)
+{
+ const char *product, *board;
+ int i;
+
+ product = dmi_get_system_info(DMI_PRODUCT_FAMILY);
+ if (!product)
+ return false;
+
+ board = dmi_get_system_info(DMI_BOARD_NAME);
+ if (!board)
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(use_hid_led_matches); i++) {
+ if (strstr(product, use_hid_led_matches[i]))
+ return true;
+ if (strstr(board, use_hid_led_matches[i]))
+ return true;
+ }
+ return false;
+}
+EXPORT_SYMBOL_GPL(asus_use_hid_led);
+
static void asus_wmi_led_exit(struct asus_wmi *asus)
{
led_classdev_unregister(&asus->kbd_led);
@@ -1681,7 +1713,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
goto error;
}
- if (!kbd_led_read(asus, &led_val, NULL)) {
+ if (!kbd_led_read(asus, &led_val, NULL) && !asus_use_hid_led()) {
+ pr_info("using asus-wmi for asus::kbd_backlight\n");
asus->kbd_led_wk = led_val;
asus->kbd_led.name = "asus::kbd_backlight";
asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 3eb5cd6773ad..6833035f7006 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -160,4 +160,14 @@ static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
}
#endif
+/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
+#if IS_ENABLED(CONFIG_ASUS_WMI)
+bool asus_use_hid_led(void);
+#else
+static inline bool asus_use_hid_led(void)
+{
+ return true;
+}
+#endif
+
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */
--
2.45.1
^ permalink raw reply related
* [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control
From: Luke D. Jones @ 2024-05-29 1:28 UTC (permalink / raw)
To: jikos
Cc: hdegoede, ilpo.jarvinen, corentin.chary, platform-driver-x86,
linux-kernel, linux-input, bentiss, Luke D. Jones
In-Reply-To: <20240529012827.146005-1-luke@ljones.dev>
On some laptops the report_id used for LED brightness control must be
0x5D instead of 0x5A.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/hid/hid-asus.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 4cba8e143031..ec3556cc4eef 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -94,6 +94,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
#define TRKID_SGN ((TRKID_MAX + 1) >> 1)
+static const char * const use_alt_led_report_id[] = { "GU605", "GA403" };
+
struct asus_kbd_leds {
struct led_classdev cdev;
struct hid_device *hdev;
@@ -101,6 +103,7 @@ struct asus_kbd_leds {
unsigned int brightness;
spinlock_t lock;
bool removed;
+ int report_id;
};
struct asus_touchpad_info {
@@ -473,7 +476,7 @@ static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
static void asus_kbd_backlight_work(struct work_struct *work)
{
struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
- u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
+ u8 buf[] = { led->report_id, 0xba, 0xc5, 0xc4, 0x00 };
int ret;
unsigned long flags;
@@ -513,6 +516,23 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
}
+static bool asus_kbd_is_input_led(void)
+{
+ const char *product;
+ int i;
+
+ product = dmi_get_system_info(DMI_PRODUCT_NAME);
+ if (!product)
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(use_alt_led_report_id); i++) {
+ if (strstr(product, use_alt_led_report_id[i]))
+ return true;
+ }
+
+ return false;
+}
+
static int asus_kbd_register_leds(struct hid_device *hdev)
{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -555,6 +575,10 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
if (!drvdata->kbd_backlight)
return -ENOMEM;
+ drvdata->kbd_backlight->report_id = FEATURE_KBD_REPORT_ID;
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_kbd_is_input_led())
+ drvdata->kbd_backlight->report_id = FEATURE_KBD_LED_REPORT_ID1;
+
drvdata->kbd_backlight->removed = false;
drvdata->kbd_backlight->brightness = 0;
drvdata->kbd_backlight->hdev = hdev;
--
2.45.1
^ permalink raw reply related
* Re: [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control
From: Luke Jones @ 2024-05-29 1:30 UTC (permalink / raw)
To: Jiri Kosina
Cc: Hans de Goede, Ilpo Järvinen, corentin.chary,
platform-driver-x86, linux-kernel, linux-input, bentiss
In-Reply-To: <20240529012447.145088-2-luke@ljones.dev>
Sorry about the doubleup. Wifi is spotty and it looked like the initial send didn't work.
See https://lore.kernel.org/linux-input/20240529012827.146005-1-luke@ljones.dev/T/#t for cover-letter
On Wed, 29 May 2024, at 1:24 PM, Luke D. Jones wrote:
> On some laptops the report_id used for LED brightness control must be
> 0x5D instead of 0x5A.
>
> Signed-off-by: Luke D. Jones <luke@ljones.dev>
> ---
> drivers/hid/hid-asus.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 4cba8e143031..ec3556cc4eef 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -94,6 +94,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
>
> #define TRKID_SGN ((TRKID_MAX + 1) >> 1)
>
> +static const char * const use_alt_led_report_id[] = { "GU605", "GA403" };
> +
> struct asus_kbd_leds {
> struct led_classdev cdev;
> struct hid_device *hdev;
> @@ -101,6 +103,7 @@ struct asus_kbd_leds {
> unsigned int brightness;
> spinlock_t lock;
> bool removed;
> + int report_id;
> };
>
> struct asus_touchpad_info {
> @@ -473,7 +476,7 @@ static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
> static void asus_kbd_backlight_work(struct work_struct *work)
> {
> struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
> - u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
> + u8 buf[] = { led->report_id, 0xba, 0xc5, 0xc4, 0x00 };
> int ret;
> unsigned long flags;
>
> @@ -513,6 +516,23 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
> return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
> }
>
> +static bool asus_kbd_is_input_led(void)
> +{
> + const char *product;
> + int i;
> +
> + product = dmi_get_system_info(DMI_PRODUCT_NAME);
> + if (!product)
> + return false;
> +
> + for (i = 0; i < ARRAY_SIZE(use_alt_led_report_id); i++) {
> + if (strstr(product, use_alt_led_report_id[i]))
> + return true;
> + }
> +
> + return false;
> +}
> +
> static int asus_kbd_register_leds(struct hid_device *hdev)
> {
> struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> @@ -555,6 +575,10 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
> if (!drvdata->kbd_backlight)
> return -ENOMEM;
>
> + drvdata->kbd_backlight->report_id = FEATURE_KBD_REPORT_ID;
> + if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_kbd_is_input_led())
> + drvdata->kbd_backlight->report_id = FEATURE_KBD_LED_REPORT_ID1;
> +
> drvdata->kbd_backlight->removed = false;
> drvdata->kbd_backlight->brightness = 0;
> drvdata->kbd_backlight->hdev = hdev;
> --
> 2.45.1
>
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox