Re: [PATCH v1 1/2] input: rmi4: fix RMI_2D clipping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Svyatoslav,

On Wed, Sep 03, 2025 at 07:19:45PM +0300, Svyatoslav Ryhel wrote:
> From: Jonas Schwöbel <jonasschwoebel@xxxxxxxx>
> 
> The physical max_y value was overridden with a clip_y_max value. This
> caused problems when inverting/flipping the screen. Further it messed up
> calculation of resolution.
> 
> Signed-off-by: Jonas Schwöbel <jonasschwoebel@xxxxxxxx>
> Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
> ---
>  drivers/input/rmi4/rmi_2d_sensor.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
> index b7fe6eb35a4e..b4762b3c8b24 100644
> --- a/drivers/input/rmi4/rmi_2d_sensor.c
> +++ b/drivers/input/rmi4/rmi_2d_sensor.c
> @@ -56,7 +56,7 @@ void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
>  		obj->x = min(sensor->max_x, obj->x);
>  
>  	if (axis_align->clip_y_high)
> -		obj->y =  min(sensor->max_y, obj->y);
> +		obj->y =  min(axis_align->clip_y_high, obj->y);
>  
>  	sensor->tracking_pos[slot].x = obj->x;
>  	sensor->tracking_pos[slot].y = obj->y;
> @@ -149,13 +149,12 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
>  
>  		sensor->min_y = sensor->axis_align.clip_y_low;
>  		if (sensor->axis_align.clip_y_high)
> -			sensor->max_y = min(sensor->max_y,
> +			max_y = min(sensor->max_y,

I see that you want to have sensor->max_y to carry maximum coordinate
the sensor is capable of reporting, so that flipping works properly. If
this is the case you should also be deleting sensor->min_y and always
use 0 in its place, otherwise there is inconsistency.

You also need to deal with X coordinate in the similar fashion.

>  				sensor->axis_align.clip_y_high);
>  
>  		set_bit(EV_ABS, input->evbit);
>  
>  		max_x = sensor->max_x;
> -		max_y = sensor->max_y;

This makes max_y potentially uninitialized.

>  		if (sensor->axis_align.swap_axes)
>  			swap(max_x, max_y);
>  		input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);

I am unconvinced that using raw sensor coordinates to calculate
resolution is a good idea. It has potential to regress existing users. 

Thanks.

-- 
Dmitry




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux