From patchwork Tue Dec 31 02:06:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Felipe F. Tonello" X-Patchwork-Id: 3421291 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B7529F383 for ; Tue, 31 Dec 2013 02:07:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FFAA2010F for ; Tue, 31 Dec 2013 02:07:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A3DF20107 for ; Tue, 31 Dec 2013 02:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932454Ab3LaCHR (ORCPT ); Mon, 30 Dec 2013 21:07:17 -0500 Received: from mail-oa0-f45.google.com ([209.85.219.45]:38041 "EHLO mail-oa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932450Ab3LaCHL (ORCPT ); Mon, 30 Dec 2013 21:07:11 -0500 Received: by mail-oa0-f45.google.com with SMTP id o6so12736260oag.32 for ; Mon, 30 Dec 2013 18:07:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bh/oF8SrwWBY2wA+DKWBU6FN1oAePcJte05gjz5KPfE=; b=erAzlwAuG2W5m7FsDM3p+Ska0bzStfo7tDMwWDxc+58D6evkNmajAmcj21Mbt8jsjg 4c+oAq4xNj7FPIx9Mw4fJrP88VRG0RiM7uWZlKVt50HJRZZEZYNt6CwybTsKFh0fkEYx 82+iMrZMQfnwWb1LgNGk9gA+7aiRbfoqeIExzJidkGPm/WjY64phqEgMkTGZRVGYGjaJ sLswyUvpNDuCTb4EQSU1En8OuXlNABOvkPmMfihVLx9NQxix1/iwpmG12PhcS1doVHpq +6GiQmrNabdZCgi5Ez1JKNWOWyS6C+JhuH6qvFf9EOc7vgEBgskQM9Vbmw7OCVzWeJkD L+Rw== X-Gm-Message-State: ALoCoQmcuCyP3Upj6cUG9Chenz2Ljuv4YrFEdkFLLd/39lmQ88dV2f/18nivn36SuX+DIzvt9pTz X-Received: by 10.182.121.137 with SMTP id lk9mr46512611obb.32.1388455630790; Mon, 30 Dec 2013 18:07:10 -0800 (PST) Received: from localhost.localdomain.com (wsip-70-183-20-162.oc.oc.cox.net. [70.183.20.162]) by mx.google.com with ESMTPSA id tr10sm56332868obb.6.2013.12.30.18.07.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Dec 2013 18:07:10 -0800 (PST) From: "Felipe F. Tonello" To: linux-input@vger.kernel.org Cc: "Felipe F. Tonello" , linux-kernel@vger.kernel.org, Henrik Rydberg , Dmitry Torokhov Subject: [PATCH 1/2] input: mt: Add helper function to send end events Date: Mon, 30 Dec 2013 18:06:40 -0800 Message-Id: <1388455601-17033-2-git-send-email-eu@felipetonello.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1388455601-17033-1-git-send-email-eu@felipetonello.com> References: <1388455601-17033-1-git-send-email-eu@felipetonello.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: "Felipe F. Tonello" This is useful to report for users of devices that don't know anything about the suspension of the device. So users will receive a touch end event when the device is about to suspend, making it more user friendly. One example of users is the X Server with the evdev input driver. This patch make sure that the X server will propagate a touch end event to its windows. Signed-off-by: Felipe F. Tonello --- drivers/input/input-mt.c | 33 +++++++++++++++++++++++++++++++++ include/linux/input/mt.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index d398f13..6010357 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -157,6 +157,39 @@ void input_mt_report_slot_state(struct input_dev *dev, EXPORT_SYMBOL(input_mt_report_slot_state); /** + * input_mt_report_end_state() - report end touch events + * @dev: input device with allocated MT slots + * + * Reports a touch end event for current active slots (with active tracking id). + * This is useful when the device might suspend (or sleep) while there were + * still active tracking ids. + */ +void input_mt_report_end_state(struct input_dev *dev) +{ + struct input_mt *mt = dev->mt; + struct input_mt_slot *slot; + int id, i; + + if (!mt) + return; + + for (i = 0; i < mt->num_slots; ++i) { + slot = &mt->slots[i]; + slot->frame = mt->frame; + + id = input_mt_get_value(slot, ABS_MT_TRACKING_ID); + + /* if id == -1 is 'unused' */ + if (id >= 0) { + input_mt_set_value(slot, ABS_MT_TRACKING_ID, -1); + input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); + } + } +} +EXPORT_SYMBOL(input_mt_report_end_state); + + +/** * input_mt_report_finger_count() - report contact count * @dev: input device with allocated MT slots * @count: the number of contacts diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index 1b1dfa8..0e6c9f7 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h @@ -103,6 +103,8 @@ static inline bool input_is_mt_axis(int axis) void input_mt_report_slot_state(struct input_dev *dev, unsigned int tool_type, bool active); +void input_mt_report_end_state(struct input_dev *dev); + void input_mt_report_finger_count(struct input_dev *dev, int count); void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);