Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2104697ybb; Thu, 9 Apr 2020 15:22:36 -0700 (PDT) X-Google-Smtp-Source: APiQypLc8tzNlj3mnCzd9lqsoVnfE+umvsG4iF32/cfssekMyOebaYNZCr28M+BoLsEJkIp9t68s X-Received: by 2002:ad4:4f93:: with SMTP id em19mr2475404qvb.110.1586470956183; Thu, 09 Apr 2020 15:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586470956; cv=none; d=google.com; s=arc-20160816; b=ayN1KSJ7mwzguVnVU7T8VBp685E84In3+CP7VGbk17uWsUQH/cc6fjrQ5JUS2ZVn/u DopyGRBhW4oGmQiwGJhvO/at8SA5k6w9TI7QyQlvn7j3JXRtN3yAnzFaopPI6pYF/uvY iQVqM4AnA850TGkCc8APNCZlTtinu0i9/F41XM4yK6OsI2yd7ar3o+CPp/ElEURF6voa Vzhg6hIph/AOubQPp/RYnjtQlcNVlwbPLntPt/EQN9E2mZAg2DtTmwBcVUgMQIovZaKh soEPdxOpvwh69Nlr7HzqUR+2Gwvbml9YZf/yo7x8wRa/TPTLMt5HQ9Mvf+N9+EsRspy+ T0Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=cc4K0Fv3unXN/awHDJ+WRBJbMk8wTw2VN2o/LlMFCjA=; b=NLegxHAUiEs+odmjLIYVYCSuKQZSXrzn3ZQpiRHBq9ikH95MwqIsgF5NPIjPWzxMy/ Ygl4H/wmLPLB6JEFL109yhzwQeeet/7/mr4mTMet7uUoRB8EWMt24QYKKn+ZdK3QbYF+ gLgcGzf9XEgRUV+RyYDaUI47wqw7e5DuRoKs/2sgolnkF940OH2ZfS/Zg46uEr4+WAFx pFDazmHp5YwG+GTxVYhVCBBO+er7mgT8jtMQbJ91kkxL2eb8HjlQKAENpsUrwnu68uto D4QSkl2BljSMlzt9BskwDJyCH2a61rOdOEtLJQglJUG8COWgg3cml7zCh5PeaMIlC0qx yDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AybwdDI/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si44153qtr.400.2020.04.09.15.22.21; Thu, 09 Apr 2020 15:22:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AybwdDI/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726722AbgDIWVP (ORCPT + 99 others); Thu, 9 Apr 2020 18:21:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:57144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbgDIWVP (ORCPT ); Thu, 9 Apr 2020 18:21:15 -0400 Received: from pobox.suse.cz (prg-ext-pat.suse.com [213.151.95.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A5EE2083E; Thu, 9 Apr 2020 22:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586470875; bh=Jppb1obNkX1IeI3tjxBViiA7iN4ydeaVqv01zbXI0WA=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=AybwdDI/rjq6JeEpISwPayKV7Ui/fiWUlgsjQjGJhLkpTw6uW22lZmrsIb+Ll7JPL J2aiBEfqqxY2/v5Wrx9qqGSh/L0SjYf6GLa2GHKl5nFqCxdIM9QAfCyM/ERpCyr9dy 2m4zxvvLv7wQ7MGKO/gw4LorqgirvpaXS1Hccjso= Date: Fri, 10 Apr 2020 00:21:12 +0200 (CEST) From: Jiri Kosina To: Artem Borisov cc: Benjamin Tissoires , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Masaki Ota Subject: Re: [PATCH 2/2] HID: alps: Refactor axis resolution logic In-Reply-To: <20200405235517.18203-2-dedsa2002@gmail.com> Message-ID: References: <20200405235517.18203-1-dedsa2002@gmail.com> <20200405235517.18203-2-dedsa2002@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 6 Apr 2020, Artem Borisov wrote: > AUI1657 doesn't follow the same logic for resolution calculation, since > the resulting values are incorrect. Instead, it reports the actual > resolution values in place of the pitch ones. > While we're at it, also refactor the whole resolution logic to make it more > generic and sensible for multiple device support. Let's add Masaki Ota to ack this change if possible. Would it be possible to be a little bit more verbose in the changelog, explaining *how* (or why) is the patch making the logic more generic and sensible? Thanks! > Signed-off-by: Artem Borisov > --- > drivers/hid/hid-alps.c | 41 +++++++++++++++++++++++++---------------- > 1 file changed, 25 insertions(+), 16 deletions(-) > > diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c > index c2a2bd528890..494c08cca645 100644 > --- a/drivers/hid/hid-alps.c > +++ b/drivers/hid/hid-alps.c > @@ -83,8 +83,8 @@ enum dev_num { > * @max_fingers: total number of fingers > * @has_sp: boolean of sp existense > * @sp_btn_info: button information > - * @x_active_len_mm: active area length of X (mm) > - * @y_active_len_mm: active area length of Y (mm) > + * @x_res: resolution of X > + * @y_res: resolution of Y > * @x_max: maximum x coordinate value > * @y_max: maximum y coordinate value > * @x_min: minimum x coordinate value > @@ -100,9 +100,10 @@ struct alps_dev { > enum dev_num dev_type; > u8 max_fingers; > u8 has_sp; > + u8 no_pitch; > u8 sp_btn_info; > - u32 x_active_len_mm; > - u32 y_active_len_mm; > + u32 x_res; > + u32 y_res; > u32 x_max; > u32 y_max; > u32 x_min; > @@ -550,10 +551,6 @@ static int u1_init(struct hid_device *hdev, struct alps_dev *pri_data) > dev_err(&hdev->dev, "failed U1_RESO_DWN_ABS (%d)\n", ret); > goto exit; > } > - pri_data->x_active_len_mm = > - (pitch_x * (sen_line_num_x - 1)) / 10; > - pri_data->y_active_len_mm = > - (pitch_y * (sen_line_num_y - 1)) / 10; > > pri_data->x_max = > (resolution << 2) * (sen_line_num_x - 1); > @@ -562,6 +559,18 @@ static int u1_init(struct hid_device *hdev, struct alps_dev *pri_data) > (resolution << 2) * (sen_line_num_y - 1); > pri_data->y_min = 1; > > + if (pri_data->no_pitch) { > + pri_data->x_res = pitch_x; > + pri_data->y_res = pitch_y; > + } else { > + pri_data->x_res = > + (pri_data->x_max - 1) / > + ((pitch_x * (sen_line_num_x - 1)) / 10); > + pri_data->y_res = > + (pri_data->y_max - 1) / > + ((pitch_y * (sen_line_num_y - 1)) / 10); > + } > + > ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN, > &tmp, 0, true); > if (ret < 0) { > @@ -622,7 +631,7 @@ static int T4_init(struct hid_device *hdev, struct alps_dev *pri_data) > pri_data->x_min = T4_COUNT_PER_ELECTRODE; > pri_data->y_max = sen_line_num_y * T4_COUNT_PER_ELECTRODE; > pri_data->y_min = T4_COUNT_PER_ELECTRODE; > - pri_data->x_active_len_mm = pri_data->y_active_len_mm = 0; > + pri_data->x_res = pri_data->y_res = 0; > pri_data->btn_cnt = 1; > > ret = t4_read_write_register(hdev, PRM_SYS_CONFIG_1, &tmp, 0, true); > @@ -675,7 +684,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) > struct alps_dev *data = hid_get_drvdata(hdev); > struct input_dev *input = hi->input, *input2; > int ret; > - int res_x, res_y, i; > + int i; > > data->input = input; > > @@ -706,12 +715,9 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) > input_set_abs_params(input, ABS_MT_POSITION_Y, > data->y_min, data->y_max, 0, 0); > > - if (data->x_active_len_mm && data->y_active_len_mm) { > - res_x = (data->x_max - 1) / data->x_active_len_mm; > - res_y = (data->y_max - 1) / data->y_active_len_mm; > - > - input_abs_set_res(input, ABS_MT_POSITION_X, res_x); > - input_abs_set_res(input, ABS_MT_POSITION_Y, res_y); > + if (data->x_res && data->y_res) { > + input_abs_set_res(input, ABS_MT_POSITION_X, data->x_res); > + input_abs_set_res(input, ABS_MT_POSITION_Y, data->y_res); > } > > input_set_abs_params(input, ABS_MT_PRESSURE, 0, 64, 0, 0); > @@ -802,8 +808,11 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id) > break; > case HID_DEVICE_ID_ALPS_U1_DUAL: > case HID_DEVICE_ID_ALPS_U1: > + data->dev_type = U1; > + break; > case HID_DEVICE_ID_ALPS_1657: > data->dev_type = U1; > + data->no_pitch = 1; > break; > default: > data->dev_type = UNKNOWN; > -- > 2.26.0 > -- Jiri Kosina SUSE Labs