Commit Graph

123 Commits

Author SHA1 Message Date
Fabio Baltieri 32fafc7176 input: analog_axis: add output inversion
The driver right now only allows inverting the input value, which can be
useful for differential channels but is quite confusing for single ended
ones. Implement a simple output inversion flag instead to make up for
that.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 20:47:18 +03:00
Fabio Baltieri 03f1dd413d input: paw32xx: only reschedule the handler if motion is asserted
The motion event handler is currently setup to always retrigger until
there's no more motion data from the sensor. Change that to only
retrigger if the motion pin is asserted when the handler has finished
running, this saves a bunch of unnecessary spi transactions.

Ideally this driver would use a level interrupt, but I'd rather avoid
that as that is unsupported by many gpio controllers.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 15:17:38 +03:00
Tim Lin c79432e108 drivers/input: it8xxx2: Add critical section to prevent race conditions
The KBS_KSOH1 register contains both keyboard and GPIO output settings.
Not all bits are for the keyboard will be driven, so a critical section
is needed to prevent race conditions.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-07-01 09:04:14 -04:00
Fabio Baltieri 96815be5f7 input: pinnacle: fix return value check for WAIT_FOR
WAIT_FOR returns type in this case is a boolean, use a boolean as
variable and check.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-06-27 15:16:05 -04:00
Jordan Yates 07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Fabio Baltieri 12405a64d4 input: analog_axis: implement power management support
Implement suspend and resume, just stop and restart the timer that kicks
the main thread update cycles.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-06-14 19:22:25 +02:00
Peter van der Perk e017006be4 drivers: input: sbus remote controller support
Add support SBUS RC controller connected through UART

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2024-06-06 15:56:38 -05:00
Fabio Baltieri 7a538c88cd input: gpio_keys: skip change checking when suspended
Check if the driver is suspended in gpio_keys_change_deferred(), this
avoids a potential situation where a race condition could try and read
from a pin that has just been disconnected.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-16 14:02:36 +02:00
Jordan Yates d725666b2c sensor: convert ADC `depends on` to `select`
When a sensor that depends on an ADC is enabled in devicetree, enable
the ADC subsystem. ADC is roughly equivalent to a bus for these sensors
(the mechanism through which data is transferred), which had the same
conversion applied in #48707.

The same benefits apply here, namely removing the need for the following
pattern in board `.kconfig` files:
```
configdefault ADC
    default y if SENSOR
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-16 13:31:32 +02:00
Fabio Baltieri d8476170bf input: it8xxx2_kbd: mask out KSOL and KSOH1 register access
KSOL and KSOH1 registers are used not only by the kbd driver, but
potentially by other GPIOs attached to the keyboard scanning pins. Mask
write access to those registers to ensure drivers don't step over each
other.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-08 12:03:15 +02:00
Fabio Baltieri 2e36c898c9 input: it8xxx2_kbd: fix col_size build warning range
Fix the range check for col_size to allow a configuration with less than
16 columns. Not sure why the minimum was set so high but there's no
reason I can tell for it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-08 12:03:15 +02:00
Fabio Baltieri 37c23f69f2 input: analog_axis: use k_sem for locking
Swap the mutex with a semaphore for locking the calibration data.
Lighter data structure, no need to use a mutex here.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-01 22:56:07 +01:00
Fabio Baltieri 4a5fa01694 input: add a paw32xx driver
Add a driver for PAW32xx sensors.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-04-23 22:13:51 +00:00
Nicolas Goualard d9fd292f4b drivers: input: CHSC6X Driver
Added a driver for the CHSC6X chip used on the
Seeed Studio Round Display for Xiao

Signed-off-by: Nicolas Goualard <nicolas.goualard@sfr.fr>
2024-04-08 09:28:36 -04:00
Ilia Kharin 828a0c04a1 drivers: input: pinnacle: add driver for trackpad
The initial version of an input driver for Cirque Pinnacle ASIC supports:
 * Setting sensitivity
 * Choosing between relative and absolute modes
  * Relative mode
   * Primary tap
   * Swapping X and Y
  * Absolute mode
   * Setting number of idle packets
   * Clipping coordinates outside of active range
   * Scaling coordinates
   * Inverting X and Y coordinates

Signed-off-by: Ilia Kharin <akscram@gmail.com>
2024-04-04 09:46:06 +01:00
Jason Yu d5b1a7d929 driver: input: gt911: Support case that no dedicated reset pin
On some boards, there is not dedicated reset pin for GT911, it might
be the same pin with display IC, or might be tighted to a high level
voltage.
This patch makes the rst_gpio can be empty.

Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
2024-04-02 15:35:50 +01:00
Fabio Baltieri 55c14e6fa6 input: analog_axis: rework deadzone calibration code
Rework the data scaling algorithm for the "deadzone" mode so that the
deadzone is subtracted from the input rather than from the output. This
makes the whole output range usable rather than making the output jump
from the center value to the minimum deadzone range.

This changes the calibration data structure as well so now all values
refer to the input data, which is more coherent.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-26 11:10:10 -04:00
Fabio Baltieri 1b2bb0dbf2 input: analog_axis: fix the variable name for calibration
Use a coherent name for the calibration data structure variable name.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-26 11:10:10 -04:00
Clement Dysli bc140e1a36 drivers: input: add cf1133 controller touchscreen
The driver allows to use CF1133 controller touchscreen (I2C)

Signed-off-by: Clement Dysli <clementdy@kickmaker.net>
2024-03-26 09:24:43 +00:00
Fabio Baltieri c82b38c7be input: pmw3610: run the whole init with spi clock on
Move the pmw3610_spi_clk_on and pmw3610_spi_clk_off calls so that the
"on" call is before the first write. The datasheet calls for doing this
before any write operations, though some writes seems to work without
this in place, other seems to behave erroneously.

The non static functions do it on their own as they can be called
separately.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-20 09:02:50 +01:00
Fabio Baltieri 2c5b992209 input: pmw3610: add few config options
Add config options for resolution, force awake and smart mode.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-20 09:02:50 +01:00
Fabio Baltieri d0a8c4158c input: gpio_keys: fix suspend race condition
Change the suspend/resume code to ensure that the interrupt are disabled
before changing the pin configuration. The current sequence has been
reported to cause spurious readouts on some platforms, this takes the
existing code and duplicates for the suspend and resume case, but swaps
the interrupt disable and configure for the suspend case.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-14 17:03:01 -05:00
Fabio Baltieri 154b2b9c1c input: pat912x: fix build with default cpi setting
Fix up the BUILD_ASSERT so that it does not trigger if the resolution
cpi is not specified in the devicetree and left to the default value.
Also use the correct spelling for "cpi".

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-14 09:47:36 +00:00
Glenn Andrews 2f691ad8de Driver Input: FT5336 reports touch pressed on no touches
See https://github.com/zephyrproject-rtos/zephyr/discussions/69997

The driver thinks that when there are zero touches, the screen is
pressed. This changes it so zero touches mean the screen is not
pressed.

Also, multi-touch is now considered a single touch, and the
TOUCH_ID is checked so that only valid touches are registered.

Signed-off-by: Glenn Andrews <glenn.andrews.42@gmail.com>
2024-03-13 11:39:19 -05:00
Fabio Baltieri a63b3d1de6 input: xec: use the generic keyboard code
Split the common keyboard scanning code out of the XEC specific driver
and use the generic code instead.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-12 19:30:09 -04:00
Fabio Baltieri ddd2cf1fdc input: convert kscan_mchp_xec.c driver to input
Convert the XEC keyboard scanning driver from kscan to input, add the
corresponding kscan compatibility node to the current board, build test
only.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-12 19:30:09 -04:00
Fabio Baltieri d123a4571a input: kbd_matrix: define PRIkbdrow coherently
It's not supposed to have the "%" in the macro, reuse the existin one
for the data type.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-12 19:28:40 -04:00
Robert Lubos 35502592a7 drivers: input: Fix uninitialized closest_mv variable warning
Building with GCC 9.4.0 gives the following warning/error:

  error: closest_mv may be used uninitialized in this function

This commit fixes it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-03-07 21:37:40 +00:00
Fabio Baltieri 8b9464089c input: add a pmw3610 driver
Add a driver for the Pixart PMW3610 mouse sensor device.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-06 13:34:16 +01:00
Fabio Baltieri 7d676c2331 input: pat912x: add a bunch of settings
Add devicetree based settings for resolution, axis inversion and sleep
mode enable. Keep the resolution setting in its own function so it can
be called by the application again in runtime if needed.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-04 22:10:58 +01:00
Fabio Baltieri ad9f2c599b input: kbd_matrix: skip column with empty mask
The active key mask can be used for supporting multiple keyboard layouts
with a single firmware. A possible use case is to support keyboard with
or without a numpad, in which case an entire set of columns may be
missing. Add a check to detect this condition and skip scanning that
column entirely if no keys are defined in it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-04 14:09:08 +01:00
Fabio Baltieri 3538335f5a input: add a pat912x driver
Add an initial input driver for the PixArt PAT9125EL, just core
functionalities for now, will add more configuration properties at a
later stage.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-02-29 11:53:20 +00:00
Chen Xingyu d181607f4e drivers: input: Implement driver for ADC keys
This commit introduces a driver for ADC keys, a common circuit design where
keys are connected to an ADC input via a resistor ladder.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
2024-02-26 11:35:19 +00:00
Joel Guittet 415cb65e3f drivers: input: cst816s: add alternative chip id
The CST816S chip ID have an alternative value. It seems that this
field represents in fact a version number of controller. Fix by adding
the new chip ID.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2024-02-05 14:49:33 +01:00
Fabio Baltieri 01be4aff40 input: gpio_qdec: add power management support
Add power management support to the gpio-qdec driver.

This is a bit complicated by the fact that the driver has two modes of
operation and the interrupt, timer and idle work ineract with each
other.

The suspend sequence is:
- set the suspended bit (inhibits the poll timer so that it does not
  resubmit the idle work)
- cancel the idle work (so that it does not schedule and re-set the
  interrupt or timers)
- disable interrupts (if used)
- stop the sampling timer
- disconnect the pins

The resume sequence is more or less the opposite.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-02-02 12:43:12 +01:00
Fabio Baltieri 1dd2307b3f input: gpio_qdec: add optical encoder support
Change the gpio_qdec driver to support optical encoders.

Add a property to use for defining an arbitrary number of GPIOs for the
sensing devices (typically infrared LEDs, but could also be the
biasing for the phototransistor), and one for adding a delay between
turning those on and reading the pin status.

The infrared LEDs typically consume a non negligible amount of power, so
there's also a new idle-poll-time-us property that enables two possible
modes of operation:

- if idle-poll-time-us is zero (default) the LEDs are enabled all the
  time and the driver enters polling mode using the GPIO interrupt as
  with mechanical encoders. This is usable for mains powered devices and
  has the lowest overhead on the CPU.

- if idle-poll-time-us is non zero, then the driver polls the encoder
  all the time, turning on the LEDs just before reading the state and
  shutting them off immediately after, but when the encoder is idle it
  switches the polling rate to idle-poll-time-us to save power, and only
  polls at sample-time-us when some movement is detected.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-23 09:45:57 -05:00
Fabio Baltieri 91ee5c4db2 input: gpio_qdec: rename gpio to ab_gpio
Rename gpio to ab_gpio, this is in preparation for adding another gpio
pointer.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-23 09:45:57 -05:00
Fabio Baltieri e5974b2aac input: gpio_keys: implement polling mode support
Some MCU have limitations with GPIO interrupts. Add a polling mode to
the gpio-keys driver to support those cases.

This required a bit of a refactoring of the driver data structure to add
a instance wide data, and move the pin specific pointer in the config
structure.

For polling, reuse the button 0 delayed work so we minimize the resource
waste, the two work handler functions are only referenced when used so
at least those are discarded automatically if no instance needs them.

Fix a bug in the PM structure instantiation as well.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-10 18:21:49 +00:00
Jonathan Hamberg 9c1a45cc00 posix: Fix name collision with __bswap
__bswap_ in zephyr/sys/byteorder.h conflicts with __bswap_ in host's
byteswap.h. byteswap.h from host compiler used in posix_native_64 boards
causes a compilation issue.

This commit renames __bswap_ to BSWAP_ to prevent collision.

Before this commit a compilation error can be created by adding #include
<byteswap.h> to samples/net/sockets/echo/src/socket_echo.c

This does not change external API to byteorder.h, but does change
internal implementation which some other source files depend on.

Replaced manual byteswap operations in devmem_service.c with APIs from
byteorder.h which automatically converts to CPU endianess when necessary.

Fixes #44324

Signed-off-by: Jonathan Hamberg <jonathanhamberg@gmail.com>
2024-01-10 18:13:44 +00:00
Fabio Baltieri bd8cee8683 drivers: input: add an analog-axis driver
Add an input driver to read data from an analog device, such as a
thumbstick, connected to an ADC channel, and report it as an input
device.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-10 15:05:35 +01:00
Fabio Baltieri 8ca40e5ebf drivers: input: depend on multithreading on drivers using a thread
These all require threads support to function, add a "depends on
MULTITHREADING" accordingly.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-09 11:27:44 +00:00
Fabio Baltieri bba517fa14 input: tweak actual-key-mask description
Tweak the actual-key-mask description, apply some leftover feedback from
the prevoius PR.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-08 10:23:53 +01:00
Fabio Baltieri 2a99432695 input: kbd_matrix: fail gracefully if changing an undefined key mask
Add a check to input_kbd_matrix_actual_key_mask_set() to return an error
if trying to change a key mask but the device does not define a keymask
in the first place.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-04 18:40:10 +00:00
Fabio Baltieri 4307882dd1 input: kbd_matrix: add actual key mask runtime control
Add an option to enable a input_kbd_matrix_actual_key_mask_set API to
enable or disable keys dynamically in the mask. This can be useful if
the exact key mask is determined in runtime and the device is using a
single firmware for multiple matrix configurations.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-27 16:50:21 +00:00
Fabio Baltieri 66a06d955a input: use K_KERNEL_STACK_SIZEOF to set the thread stack size
Use K_KERNEL_STACK_SIZEOF instead of the config directly to set the
stack size in k_thread_create() calls.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-23 09:59:28 +00:00
Fabio Baltieri c0e6629b7b input: npcx_kbd: setup the interrupt to falling edge only
The driver works on active low signals only, change the interrupt
configuration to trigger on falling edges only.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-20 18:07:43 +00:00
Fabio Baltieri 0442fe3bbf input: npcx_kbd: clear pending interrupts before reenabling detection
The driver right now re-enters polling mode a couple times after the
matrix has been detected as stable as the key interrupt is still pending
and fires again once detection is reenabled.

Clear pending WUI interrupts before reenabling key press detection to
avoid that.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-19 10:57:38 +00:00
Fabio Baltieri ecce235322 input: kbd_matrix: fix possible race condition
Fix a possible race condition in the keyboard matrix library where a key
would get pressed between the last read and reenabling the (edge
sensitive) interrupt and the even would be lost.

The window for this to happen is very narrow and had to artificially add
a sleep to reproduce it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-18 12:25:19 +01:00
Fabio Baltieri ffbd0397dd input: gpio_kbd_matrix: use edge-to-active interrupt
Change the interrupt setup from both edge to edge to active. Edge to
active is all was needed anyway and it makes this compatible with gpio
controller that only support single edge interrupt.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-18 12:25:19 +01:00
Fabio Baltieri f9313b1745 input: add a linux-evdev device
Add a device driver to read events from a Linux evdev device node and
inject them back as Zephyr input events.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-18 12:23:59 +01:00