Re: [PATCH v3 2/2] Input: synaptics-rmi4 - add support for F3A
On Wed, Sep 30, 2020 at 05:41:47PM +0800, Vincent Huang wrote: > RMI4 F3A supports the touchpad GPIO function, it's designed to > support more GPIOs and used on newer touchpads. This patch adds > support of the touchpad buttons. > > Signed-off-by: Vincent Huang > Reviewed-by: Hans de Goede > Tested-by: Hans de Goede Applied, thank you. -- Dmitry
Re: [PATCH v3 2/2] Input: synaptics-rmi4 - add support for F3A
On Wed, Sep 30, 2020, at 2:41 AM, Vincent Huang wrote: > RMI4 F3A supports the touchpad GPIO function, it's designed to > support more GPIOs and used on newer touchpads. This patch adds > support of the touchpad buttons. > > Signed-off-by: Vincent Huang > Reviewed-by: Hans de Goede > Tested-by: Hans de Goede Reviewed-by: Andrew Duggan > --- > drivers/input/rmi4/Kconfig | 8 ++ > drivers/input/rmi4/Makefile | 1 + > drivers/input/rmi4/rmi_bus.c| 3 + > drivers/input/rmi4/rmi_driver.h | 1 + > drivers/input/rmi4/rmi_f3a.c| 240 > 5 files changed, 253 insertions(+) > create mode 100644 drivers/input/rmi4/rmi_f3a.c > > diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig > index a212ff706f74..16119f760d11 100644 > --- a/drivers/input/rmi4/Kconfig > +++ b/drivers/input/rmi4/Kconfig > @@ -100,6 +100,14 @@ config RMI4_F34 > device via the firmware loader interface. This is triggered using a > sysfs attribute. > > +config RMI4_F3A > + bool "RMI4 Function 3A (GPIO)" > + help > + Say Y here if you want to add support for RMI4 function 3A. > + > + Function 3A provides GPIO support for RMI4 devices. This includes > + support for buttons on TouchPads and ClickPads. > + > config RMI4_F54 > bool "RMI4 Function 54 (Analog diagnostics)" > depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) > diff --git a/drivers/input/rmi4/Makefile b/drivers/input/rmi4/Makefile > index f17631656987..02f14c846861 100644 > --- a/drivers/input/rmi4/Makefile > +++ b/drivers/input/rmi4/Makefile > @@ -10,6 +10,7 @@ rmi_core-$(CONFIG_RMI4_F11) += rmi_f11.o > rmi_core-$(CONFIG_RMI4_F12) += rmi_f12.o > rmi_core-$(CONFIG_RMI4_F30) += rmi_f30.o > rmi_core-$(CONFIG_RMI4_F34) += rmi_f34.o rmi_f34v7.o > +rmi_core-$(CONFIG_RMI4_F3A) += rmi_f3a.o > rmi_core-$(CONFIG_RMI4_F54) += rmi_f54.o > rmi_core-$(CONFIG_RMI4_F55) += rmi_f55.o > > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c > index af706a583656..47d1b97ed6cf 100644 > --- a/drivers/input/rmi4/rmi_bus.c > +++ b/drivers/input/rmi4/rmi_bus.c > @@ -365,6 +365,9 @@ static struct rmi_function_handler *fn_handlers[] = { > #ifdef CONFIG_RMI4_F34 > &rmi_f34_handler, > #endif > +#ifdef CONFIG_RMI4_F3A > + &rmi_f3a_handler, > +#endif > #ifdef CONFIG_RMI4_F54 > &rmi_f54_handler, > #endif > diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h > index 65bfaa95e193..1c6c6086c0e5 100644 > --- a/drivers/input/rmi4/rmi_driver.h > +++ b/drivers/input/rmi4/rmi_driver.h > @@ -135,6 +135,7 @@ extern struct rmi_function_handler rmi_f11_handler; > extern struct rmi_function_handler rmi_f12_handler; > extern struct rmi_function_handler rmi_f30_handler; > extern struct rmi_function_handler rmi_f34_handler; > +extern struct rmi_function_handler rmi_f3a_handler; > extern struct rmi_function_handler rmi_f54_handler; > extern struct rmi_function_handler rmi_f55_handler; > #endif > diff --git a/drivers/input/rmi4/rmi_f3a.c b/drivers/input/rmi4/rmi_f3a.c > new file mode 100644 > index ..11ff35f811b0 > --- /dev/null > +++ b/drivers/input/rmi4/rmi_f3a.c > @@ -0,0 +1,240 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2012-2020 Synaptics Incorporated > + */ > + > +#include > +#include > +#include > +#include > +#include "rmi_driver.h" > + > +#define RMI_F3A_MAX_GPIO_COUNT 128 > +#define RMI_F3A_MAX_REG_SIZE DIV_ROUND_UP(RMI_F3A_MAX_GPIO_COUNT, 8) > + > +/* Defs for Query 0 */ > +#define RMI_F3A_GPIO_COUNT 0x7F > + > +#define RMI_F3A_DATA_REGS_MAX_SIZE RMI_F3A_MAX_REG_SIZE > + > +#define TRACKSTICK_RANGE_START 3 > +#define TRACKSTICK_RANGE_END 6 > + > +struct f3a_data { > + /* Query Data */ > + u8 gpio_count; > + > + u8 register_count; > + > + u8 data_regs[RMI_F3A_DATA_REGS_MAX_SIZE]; > + u16 *gpio_key_map; > + > + struct input_dev *input; > + > + struct rmi_function *f03; > + bool trackstick_buttons; > +}; > + > +static void rmi_f3a_report_button(struct rmi_function *fn, > + struct f3a_data *f3a, unsigned int button) > +{ > + u16 key_code = f3a->gpio_key_map[button]; > + bool key_down = !(f3a->data_regs[0] & BIT(button)); > + > + if (f3a->trackstick_buttons && > + button >= TRACKSTICK_RANGE_START && > + button <= TRACKSTICK_RANGE_END) { > + rmi_f03_overwrite_button(f3a->f03, key_code, key_down); > + } else { > + rmi_dbg(RMI_DEBUG_FN, &fn->dev, > + "%s: call input report key (0x%04x) value (0x%02x)", > + __func__, key_code, key_down); > + input_report_key(f3a->input, key_code, key_down); > + } > +} > + > +static irqreturn_t rmi_f3a_attention(int irq, void *ctx) > +{ > + struct rmi_function *fn = ctx; > + struct f3a_data *f3
[PATCH v3 2/2] Input: synaptics-rmi4 - add support for F3A
RMI4 F3A supports the touchpad GPIO function, it's designed to support more GPIOs and used on newer touchpads. This patch adds support of the touchpad buttons. Signed-off-by: Vincent Huang Reviewed-by: Hans de Goede Tested-by: Hans de Goede --- drivers/input/rmi4/Kconfig | 8 ++ drivers/input/rmi4/Makefile | 1 + drivers/input/rmi4/rmi_bus.c| 3 + drivers/input/rmi4/rmi_driver.h | 1 + drivers/input/rmi4/rmi_f3a.c| 240 5 files changed, 253 insertions(+) create mode 100644 drivers/input/rmi4/rmi_f3a.c diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig index a212ff706f74..16119f760d11 100644 --- a/drivers/input/rmi4/Kconfig +++ b/drivers/input/rmi4/Kconfig @@ -100,6 +100,14 @@ config RMI4_F34 device via the firmware loader interface. This is triggered using a sysfs attribute. +config RMI4_F3A + bool "RMI4 Function 3A (GPIO)" + help + Say Y here if you want to add support for RMI4 function 3A. + + Function 3A provides GPIO support for RMI4 devices. This includes + support for buttons on TouchPads and ClickPads. + config RMI4_F54 bool "RMI4 Function 54 (Analog diagnostics)" depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) diff --git a/drivers/input/rmi4/Makefile b/drivers/input/rmi4/Makefile index f17631656987..02f14c846861 100644 --- a/drivers/input/rmi4/Makefile +++ b/drivers/input/rmi4/Makefile @@ -10,6 +10,7 @@ rmi_core-$(CONFIG_RMI4_F11) += rmi_f11.o rmi_core-$(CONFIG_RMI4_F12) += rmi_f12.o rmi_core-$(CONFIG_RMI4_F30) += rmi_f30.o rmi_core-$(CONFIG_RMI4_F34) += rmi_f34.o rmi_f34v7.o +rmi_core-$(CONFIG_RMI4_F3A) += rmi_f3a.o rmi_core-$(CONFIG_RMI4_F54) += rmi_f54.o rmi_core-$(CONFIG_RMI4_F55) += rmi_f55.o diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c index af706a583656..47d1b97ed6cf 100644 --- a/drivers/input/rmi4/rmi_bus.c +++ b/drivers/input/rmi4/rmi_bus.c @@ -365,6 +365,9 @@ static struct rmi_function_handler *fn_handlers[] = { #ifdef CONFIG_RMI4_F34 &rmi_f34_handler, #endif +#ifdef CONFIG_RMI4_F3A + &rmi_f3a_handler, +#endif #ifdef CONFIG_RMI4_F54 &rmi_f54_handler, #endif diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h index 65bfaa95e193..1c6c6086c0e5 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h @@ -135,6 +135,7 @@ extern struct rmi_function_handler rmi_f11_handler; extern struct rmi_function_handler rmi_f12_handler; extern struct rmi_function_handler rmi_f30_handler; extern struct rmi_function_handler rmi_f34_handler; +extern struct rmi_function_handler rmi_f3a_handler; extern struct rmi_function_handler rmi_f54_handler; extern struct rmi_function_handler rmi_f55_handler; #endif diff --git a/drivers/input/rmi4/rmi_f3a.c b/drivers/input/rmi4/rmi_f3a.c new file mode 100644 index ..11ff35f811b0 --- /dev/null +++ b/drivers/input/rmi4/rmi_f3a.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2012-2020 Synaptics Incorporated + */ + +#include +#include +#include +#include +#include "rmi_driver.h" + +#define RMI_F3A_MAX_GPIO_COUNT 128 +#define RMI_F3A_MAX_REG_SIZE DIV_ROUND_UP(RMI_F3A_MAX_GPIO_COUNT, 8) + +/* Defs for Query 0 */ +#define RMI_F3A_GPIO_COUNT 0x7F + +#define RMI_F3A_DATA_REGS_MAX_SIZE RMI_F3A_MAX_REG_SIZE + +#define TRACKSTICK_RANGE_START 3 +#define TRACKSTICK_RANGE_END 6 + +struct f3a_data { + /* Query Data */ + u8 gpio_count; + + u8 register_count; + + u8 data_regs[RMI_F3A_DATA_REGS_MAX_SIZE]; + u16 *gpio_key_map; + + struct input_dev *input; + + struct rmi_function *f03; + bool trackstick_buttons; +}; + +static void rmi_f3a_report_button(struct rmi_function *fn, + struct f3a_data *f3a, unsigned int button) +{ + u16 key_code = f3a->gpio_key_map[button]; + bool key_down = !(f3a->data_regs[0] & BIT(button)); + + if (f3a->trackstick_buttons && + button >= TRACKSTICK_RANGE_START && + button <= TRACKSTICK_RANGE_END) { + rmi_f03_overwrite_button(f3a->f03, key_code, key_down); + } else { + rmi_dbg(RMI_DEBUG_FN, &fn->dev, + "%s: call input report key (0x%04x) value (0x%02x)", + __func__, key_code, key_down); + input_report_key(f3a->input, key_code, key_down); + } +} + +static irqreturn_t rmi_f3a_attention(int irq, void *ctx) +{ + struct rmi_function *fn = ctx; + struct f3a_data *f3a = dev_get_drvdata(&fn->dev); + struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); + int error; + int i; + + if (drvdata->attn_data.data) { + if (drvdata->attn_data.size < f3a->register_count) { + dev_warn(&fn->dev, +