Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: synaptics-rmi4 - propagate correct number of rx and tx electrodes to F54

F54 diagnostics report functions provide data based on the number of
enabled rx and tx electrodes, which is not identical to the number of
electrodes reported with F54:Query0 and F54:Query1. Those values report
the number of supported electrodes, not the number of enabled electrodes.
The number of enabled electrodes can be determined by analyzing F55:Ctrl1
(sensor receiver assignment) and F55:Ctrl2 (sensor transmitter assignment).

Propagate the number of enabled electrodes from F55 to F54 to avoid
corrupted output if not all electrodes are enabled.

Fixes: 3a762dbd5347 ("[media] Input: synaptics-rmi4 - add support for F54 ...")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Nick Dyer <nick@shmanahar.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Guenter Roeck and committed by
Dmitry Torokhov
c762cc68 6adba43f

+21 -4
+1
drivers/input/rmi4/Kconfig
··· 90 90 depends on RMI4_CORE 91 91 depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) 92 92 select VIDEOBUF2_VMALLOC 93 + select RMI4_F55 93 94 help 94 95 Say Y here if you want to add support for RMI4 function 54 95 96
+10 -4
drivers/input/rmi4/rmi_f54.c
··· 217 217 218 218 static size_t rmi_f54_get_report_size(struct f54_data *f54) 219 219 { 220 - u8 rx = f54->num_rx_electrodes ? : f54->num_rx_electrodes; 221 - u8 tx = f54->num_tx_electrodes ? : f54->num_tx_electrodes; 220 + struct rmi_device *rmi_dev = f54->fn->rmi_dev; 221 + struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); 222 + u8 rx = drv_data->num_rx_electrodes ? : f54->num_rx_electrodes; 223 + u8 tx = drv_data->num_tx_electrodes ? : f54->num_tx_electrodes; 222 224 size_t size; 223 225 224 226 switch (rmi_f54_get_reptype(f54, f54->input)) { ··· 404 402 405 403 static int rmi_f54_set_input(struct f54_data *f54, unsigned int i) 406 404 { 405 + struct rmi_device *rmi_dev = f54->fn->rmi_dev; 406 + struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); 407 + u8 rx = drv_data->num_rx_electrodes ? : f54->num_rx_electrodes; 408 + u8 tx = drv_data->num_tx_electrodes ? : f54->num_tx_electrodes; 407 409 struct v4l2_pix_format *f = &f54->format; 408 410 enum rmi_f54_report_type reptype; 409 411 int ret; ··· 422 416 423 417 f54->input = i; 424 418 425 - f->width = f54->num_rx_electrodes; 426 - f->height = f54->num_tx_electrodes; 419 + f->width = rx; 420 + f->height = tx; 427 421 f->field = V4L2_FIELD_NONE; 428 422 f->colorspace = V4L2_COLORSPACE_RAW; 429 423 f->bytesperline = f->width * sizeof(u16);
+7
drivers/input/rmi4/rmi_f55.c
··· 38 38 39 39 static int rmi_f55_detect(struct rmi_function *fn) 40 40 { 41 + struct rmi_device *rmi_dev = fn->rmi_dev; 42 + struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); 41 43 struct f55_data *f55; 42 44 int error; 43 45 ··· 58 56 59 57 f55->cfg_num_rx_electrodes = f55->num_rx_electrodes; 60 58 f55->cfg_num_tx_electrodes = f55->num_rx_electrodes; 59 + 60 + drv_data->num_rx_electrodes = f55->cfg_num_rx_electrodes; 61 + drv_data->num_tx_electrodes = f55->cfg_num_rx_electrodes; 61 62 62 63 if (f55->qry[F55_PHYS_CHAR_OFFSET] & F55_CAP_SENSOR_ASSIGN) { 63 64 int i, total; ··· 83 78 total++; 84 79 } 85 80 f55->cfg_num_rx_electrodes = total; 81 + drv_data->num_rx_electrodes = total; 86 82 } 87 83 88 84 error = rmi_read_block(fn->rmi_dev, ··· 96 90 total++; 97 91 } 98 92 f55->cfg_num_tx_electrodes = total; 93 + drv_data->num_tx_electrodes = total; 99 94 } 100 95 } 101 96
+3
include/linux/rmi.h
··· 354 354 u8 pdt_props; 355 355 u8 bsr; 356 356 357 + u8 num_rx_electrodes; 358 + u8 num_tx_electrodes; 359 + 357 360 bool enabled; 358 361 359 362 void *data;