From patchwork Wed Mar 19 01:03:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Heiny X-Patchwork-Id: 3856961 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43EDEBF549 for ; Wed, 19 Mar 2014 18:01:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A2952010F for ; Wed, 19 Mar 2014 18:01:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45EF02011B for ; Wed, 19 Mar 2014 18:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758654AbaCSBE1 (ORCPT ); Tue, 18 Mar 2014 21:04:27 -0400 Received: from [192.147.44.131] ([192.147.44.131]:15920 "EHLO us-mx2.synaptics.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1758013AbaCSBE0 (ORCPT ); Tue, 18 Mar 2014 21:04:26 -0400 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 18 Mar 2014 18:04:05 -0700 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Tue, 18 Mar 2014 17:49:29 -0700 X-PGP-Universal: processed; by securemail.synaptics.com on Tue, 18 Mar 2014 17:49:29 -0700 Received: from brontomerus.synaptics.com (10.3.20.103) by USW-OWA1.synaptics-inc.local (10.20.24.15) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 18 Mar 2014 18:04:05 -0700 From: Christopher Heiny To: Dmitry Torokhov CC: Linux Input , Christopher Heiny , Andrew Duggan , Vincent Huang , Vivian Ly , Daniel Rosenberg , Linus Walleij , Benjamin Tissoires , David Herrmann , Jiri Kosina Subject: [PATCH 3/3] Input: synaptics-rmi4 - report sensor resolution Date: Tue, 18 Mar 2014 18:03:51 -0700 Message-ID: <1395191031-3144-3-git-send-email-cheiny@synaptics.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1395191031-3144-1-git-send-email-cheiny@synaptics.com> References: <1395191031-3144-1-git-send-email-cheiny@synaptics.com> MIME-Version: 1.0 X-Originating-IP: [10.3.20.103] Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reports the sensor resolution by reading the size of the sensor from F11 query registers or from the platform data if the firmware does not contain the appropriate query registers. Signed-off-by: Andrew Duggan Acked-by: Christopher Heiny Cc: Dmitry Torokhov Cc: Benjamin Tissoires Cc: Linux Walleij Cc: David Herrmann Cc: Jiri Kosina --- drivers/input/rmi4/rmi_f11.c | 53 +++++++++++++++++++++++++++++++++++++++++++- include/linux/rmi.h | 2 ++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index f5b8b71..f2a6f5f 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c @@ -408,6 +408,10 @@ struct f11_2d_sensor_queries { u8 clickpad_props; u8 mouse_buttons; bool has_advanced_gestures; + + /* Query 15 - 18 */ + u16 x_sensor_size_mm; + u16 y_sensor_size_mm; }; /* Defs for Ctrl0. */ @@ -520,6 +524,8 @@ struct f11_2d_sensor { struct rmi_function *fn; char input_phys[NAME_BUFFER_SIZE]; char input_phys_mouse[NAME_BUFFER_SIZE]; + u8 x_mm; + u8 y_mm; u8 report_abs; u8 report_rel; }; @@ -1098,6 +1104,20 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev, query_size++; } + if (f11->has_query12 && sensor_query->has_physical_props) { + rc = rmi_read_block(rmi_dev, query_base_addr + + query_size, query_buf, ARRAY_SIZE(query_buf)); + if (rc < 0) + return rc; + + sensor_query->x_sensor_size_mm = + (query_buf[0] | (query_buf[1] << 8)) / 10; + sensor_query->y_sensor_size_mm = + (query_buf[2] | (query_buf[3] << 8)) / 10; + + query_size += 4; + } + return query_size; } @@ -1119,6 +1139,7 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11) ((f11->dev_controls.ctrl0_9[9] & 0x0F) << 8); u16 x_min, x_max, y_min, y_max; unsigned int input_flags; + int res_x, res_y; /* We assume touchscreen unless demonstrably a touchpad or specified * as a touchpad in the platform data @@ -1175,6 +1196,18 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11) x_min, x_max, 0, 0); input_set_abs_params(input, ABS_MT_POSITION_Y, y_min, y_max, 0, 0); + + if (sensor->x_mm && sensor->y_mm) { + res_x = (x_max - x_min) / sensor->x_mm; + res_y = (y_max - y_min) / sensor->y_mm; + + input_abs_set_res(input, ABS_X, res_x); + input_abs_set_res(input, ABS_Y, res_y); + + input_abs_set_res(input, ABS_MT_POSITION_X, res_x); + input_abs_set_res(input, ABS_MT_POSITION_Y, res_y); + } + if (!sensor->type_a) input_mt_init_slots(input, sensor->nbr_fingers, input_flags); if (IS_ENABLED(CONFIG_RMI4_F11_PEN) && sensor->sens_query.has_pen) @@ -1261,8 +1294,26 @@ static int rmi_f11_initialize(struct rmi_function *fn) sensor->axis_align = pdata->f11_sensor_data->axis_align; sensor->type_a = pdata->f11_sensor_data->type_a; - sensor->sensor_type = + + if (sensor->sens_query.has_info2) { + if (sensor->sens_query.is_clear) + sensor->sensor_type = + rmi_f11_sensor_touchscreen; + else + sensor->sensor_type = rmi_f11_sensor_touchpad; + } else { + sensor->sensor_type = pdata->f11_sensor_data->sensor_type; + } + + if (f11->has_query12 + && sensor->sens_query.has_physical_props) { + sensor->x_mm = sensor->sens_query.x_sensor_size_mm; + sensor->y_mm = sensor->sens_query.y_sensor_size_mm; + } else { + sensor->x_mm = pdata->f11_sensor_data->x_mm; + sensor->y_mm = pdata->f11_sensor_data->y_mm; + } if (sensor->sens_query.has_abs) sensor->report_abs = sensor->report_abs diff --git a/include/linux/rmi.h b/include/linux/rmi.h index a0d0187..9139873 100644 --- a/include/linux/rmi.h +++ b/include/linux/rmi.h @@ -96,6 +96,8 @@ struct rmi_f11_sensor_data { struct rmi_f11_2d_axis_alignment axis_align; bool type_a; enum rmi_f11_sensor_type sensor_type; + int x_mm; + int y_mm; int disable_report_mask; };