diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-06-29 10:29:46 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-06-29 10:29:46 -0700 |
commit | 86e203edf24bb327ce8fcd3c5c8c6bf530a846df (patch) | |
tree | 96432b49ba58fc5814b51fd5a9a8f58fe3ee56ec /include | |
parent | 0e382fa72bbf0610be40af9af9b03b0cd149df82 (diff) | |
parent | bf4ed21778f2920ca91a32fd3a1e1130e843e98f (diff) |
Merge tag 'input-for-v6.5-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov:
- improvements to PS/2 handling for case when EC has already latched a
scancode in the data register, but the kernel expects to receive an
ACK to a command it sent to a device (such as keyboard LED toggle)
- input drivers for devices connected over I2C bus have been switched
back to using [new] .probe()
- uinput allows userspace to inject timestamps for input events
- support for capacitive keys in Atmel touch controller driver
- assorted fixes to drv260x, pwm-vibra, ili210x, adxl34x, and other
drivers
* tag 'input-for-v6.5-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (40 commits)
Input: pm8941-powerkey - fix debounce on gen2+ PMICs
MAINTAINERS: Adjust Qualcomm driver globbing
Input: gameport - provide default trigger() and read()
Input: tps65219-pwrbutton - use regmap_set_bits()
Input: tps65219-pwrbutton - convert to .remove_new()
Input: tests - add test to cover all input_grab_device() function
Input: gpio-keys - use input_report_key()
Input: xpad - spelling fixes for "Xbox"
Input: add HAS_IOPORT dependencies
Input: libps2 - do not discard non-ack bytes when controlling LEDs
Input: libps2 - introduce common interrupt handler
Input: libps2 - fix aborting PS/2 commands
Input: libps2 - fix NAK handling
Input: libps2 - rework handling of command response
Input: libps2 - remove special handling of ACK for command byte
Input: libps2 - attach ps2dev instances as serio port's drvdata
Input: Switch i2c drivers back to use .probe()
dt-bindings: input: cypress,cyapa: convert to dtschema
Input: adxl34x - do not hardcode interrupt trigger type
Input: pwm-vibra - add support for enable GPIO
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/gameport.h | 11 | ||||
-rw-r--r-- | include/linux/i8042.h | 1 | ||||
-rw-r--r-- | include/linux/libps2.h | 62 |
3 files changed, 41 insertions, 33 deletions
diff --git a/include/linux/gameport.h b/include/linux/gameport.h index 8c2f00018e89..0a221e768ea4 100644 --- a/include/linux/gameport.h +++ b/include/linux/gameport.h @@ -5,7 +5,6 @@ #ifndef _GAMEPORT_H #define _GAMEPORT_H -#include <asm/io.h> #include <linux/types.h> #include <linux/list.h> #include <linux/mutex.h> @@ -165,18 +164,12 @@ void gameport_unregister_driver(struct gameport_driver *drv); static inline void gameport_trigger(struct gameport *gameport) { - if (gameport->trigger) - gameport->trigger(gameport); - else - outb(0xff, gameport->io); + gameport->trigger(gameport); } static inline unsigned char gameport_read(struct gameport *gameport) { - if (gameport->read) - return gameport->read(gameport); - else - return inb(gameport->io); + return gameport->read(gameport); } static inline int gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) diff --git a/include/linux/i8042.h b/include/linux/i8042.h index 0261e2fb3636..95b07f8b77fe 100644 --- a/include/linux/i8042.h +++ b/include/linux/i8042.h @@ -3,6 +3,7 @@ #define _LINUX_I8042_H +#include <linux/errno.h> #include <linux/types.h> /* diff --git a/include/linux/libps2.h b/include/linux/libps2.h index 53f7e4d0f4b7..9ca9ce4e6e64 100644 --- a/include/linux/libps2.h +++ b/include/linux/libps2.h @@ -8,44 +8,59 @@ */ #include <linux/bitops.h> +#include <linux/interrupt.h> #include <linux/mutex.h> #include <linux/types.h> #include <linux/wait.h> -#define PS2_CMD_SETSCALE11 0x00e6 -#define PS2_CMD_SETRES 0x10e8 -#define PS2_CMD_GETID 0x02f2 -#define PS2_CMD_RESET_BAT 0x02ff +struct ps2dev; -#define PS2_RET_BAT 0xaa -#define PS2_RET_ID 0x00 -#define PS2_RET_ACK 0xfa -#define PS2_RET_NAK 0xfe -#define PS2_RET_ERR 0xfc +/** + * enum ps2_disposition - indicates how received byte should be handled + * @PS2_PROCESS: pass to the main protocol handler, process normally + * @PS2_IGNORE: skip the byte + * @PS2_ERROR: do not process the byte, abort command in progress + */ +enum ps2_disposition { + PS2_PROCESS, + PS2_IGNORE, + PS2_ERROR, +}; -#define PS2_FLAG_ACK BIT(0) /* Waiting for ACK/NAK */ -#define PS2_FLAG_CMD BIT(1) /* Waiting for a command to finish */ -#define PS2_FLAG_CMD1 BIT(2) /* Waiting for the first byte of command response */ -#define PS2_FLAG_WAITID BIT(3) /* Command executing is GET ID */ -#define PS2_FLAG_NAK BIT(4) /* Last transmission was NAKed */ -#define PS2_FLAG_ACK_CMD BIT(5) /* Waiting to ACK the command (first) byte */ +typedef enum ps2_disposition (*ps2_pre_receive_handler_t)(struct ps2dev *, u8, + unsigned int); +typedef void (*ps2_receive_handler_t)(struct ps2dev *, u8); +/** + * struct ps2dev - represents a device using PS/2 protocol + * @serio: a serio port used by the PS/2 device + * @cmd_mutex: a mutex ensuring that only one command is executing at a time + * @wait: a waitqueue used to signal completion from the serio interrupt handler + * @flags: various internal flags indicating stages of PS/2 command execution + * @cmdbuf: buffer holding command response + * @cmdcnt: outstanding number of bytes of the command response + * @nak: a byte transmitted by the device when it refuses command + * @pre_receive_handler: checks communication errors and returns disposition + * (&enum ps2_disposition) of the received data byte + * @receive_handler: main handler of particular PS/2 protocol, such as keyboard + * or mouse protocol + */ struct ps2dev { struct serio *serio; - - /* Ensures that only one command is executing at a time */ struct mutex cmd_mutex; - - /* Used to signal completion from interrupt handler */ wait_queue_head_t wait; - unsigned long flags; u8 cmdbuf[8]; u8 cmdcnt; u8 nak; + + ps2_pre_receive_handler_t pre_receive_handler; + ps2_receive_handler_t receive_handler; }; -void ps2_init(struct ps2dev *ps2dev, struct serio *serio); +void ps2_init(struct ps2dev *ps2dev, struct serio *serio, + ps2_pre_receive_handler_t pre_receive_handler, + ps2_receive_handler_t receive_handler); int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout); void ps2_drain(struct ps2dev *ps2dev, size_t maxbytes, unsigned int timeout); void ps2_begin_command(struct ps2dev *ps2dev); @@ -53,9 +68,8 @@ void ps2_end_command(struct ps2dev *ps2dev); int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command); int ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command); int ps2_sliced_command(struct ps2dev *ps2dev, u8 command); -bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data); -bool ps2_handle_response(struct ps2dev *ps2dev, u8 data); -void ps2_cmd_aborted(struct ps2dev *ps2dev); bool ps2_is_keyboard_id(u8 id); +irqreturn_t ps2_interrupt(struct serio *serio, u8 data, unsigned int flags); + #endif /* _LIBPS2_H */ |