From patchwork Fri Nov 27 10:00:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingbo Wen X-Patchwork-Id: 57360 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1031754lbb; Fri, 27 Nov 2015 02:02:10 -0800 (PST) X-Received: by 10.98.1.140 with SMTP id 134mr45431932pfb.134.1448618530243; Fri, 27 Nov 2015 02:02:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cz6si21355870pad.187.2015.11.27.02.02.10; Fri, 27 Nov 2015 02:02:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754611AbbK0KCI (ORCPT + 1 other); Fri, 27 Nov 2015 05:02:08 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:36287 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754256AbbK0KBV (ORCPT ); Fri, 27 Nov 2015 05:01:21 -0500 Received: by pacdm15 with SMTP id dm15so111018711pac.3 for ; Fri, 27 Nov 2015 02:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SR5WMfXmvOhrSXLmhEhYrOMPP0hY0wuKNB/SZfTpFyM=; b=IgB2nIlDaxnZwZk6JBhCXuCp07Zs0GFJrUwPX8FNmcjjKYbQ7iG4LnNOGWuivVHWf8 x7rVBZBX19HCj6TPfXumyXbv6Jxm3ANFAr+2mzpod9i2Yypoiq6Mc96I9BysNCm5ei1k 93OjczNPaY0DC3QapVGyYKN1NybL7bGni3h6597pI63zswoXbMkLGj/BI68J0U14Ier4 sNANQU0c0DaCdLZj5WsKJvdRszNhmKGeNDNxkB9Ek+VpPyn0uxLBqroPkWX6lRwwjBBY HxHzGTDht8aDL11wdyJTHS8eBtEt24g8EtK7lpuClEh0Z0aIubjDZ/LUtT76yPKYeUDN 2Hcg== 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=SR5WMfXmvOhrSXLmhEhYrOMPP0hY0wuKNB/SZfTpFyM=; b=NPAwO65GN7YVmr6seAcfSi0ZPOq3Z9UjR8PahvyS+BmoSF6h+zWO+40kgp4RCIb41U CriCC5Onm0u7ht5AuD4wIgobXA8SQGF7jE15Kn8B6il9fHi9pY7h+5luFbPader2r1E4 qEZ+lYCiGNKAQGqbGL/2wtzPg5VC1ijkk0FNgbfec2+KMhV9h1Nyz7ObUDkKj+iRm46i rVHnjaukzSwM3sFRfL6Zuzpu4u+E88bwD3rgOraXaw2gG8C3vnsKCqKkS+AO5tkFxsjB JOtiWMfVrEmw0H9QjyZT4AGxkV1+AmZfJcE/i8048Z0FgiYpOPeL3J1HUpP7VaAahnk2 AeFg== X-Gm-Message-State: ALoCoQkHOb4RfMInfTjFBEzB2uxeMQ0+ZgI6Pq2UNDPXO7E22O/ZyfQ28cX78FRx4wG+4VlpJZw2 X-Received: by 10.66.217.166 with SMTP id oz6mr37686400pac.96.1448618481024; Fri, 27 Nov 2015 02:01:21 -0800 (PST) Received: from localhost.localdomain ([103.26.122.10]) by smtp.gmail.com with ESMTPSA id tm4sm31768969pab.3.2015.11.27.02.01.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Nov 2015 02:01:20 -0800 (PST) From: WEN Pingbo To: y2038@list.linaro.org, dmitry.torokhov@gmail.com, aksgarg1989@gmail.com, arnd@arndb.de Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, WEN Pingbo Subject: [PATCH 2/3] input: evdev: add new ioctl EVIOCSIFTYPE / EVIOCGIFTYPE Date: Fri, 27 Nov 2015 18:00:31 +0800 Message-Id: <1448618432-32357-3-git-send-email-pingbo.wen@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448618432-32357-1-git-send-email-pingbo.wen@linaro.org> References: <1448618432-32357-1-git-send-email-pingbo.wen@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch depends on 'introduce new evdev interface'. Userspace cat set / get evdev interface type via the two ioctl commands. And default interface type is EV_IF_LEGACY, so the old binary will work normal with new kernel. Maybe we should change this default option to encourage people to move to new interface. And since all events are stored as input_value in evdev, there are no need to flush evdev_client's buffer if we change clk_type and if_type. Signed-off-by: WEN Pingbo --- drivers/input/evdev.c | 39 +++++++++++++++++++++++++++------------ include/uapi/linux/input.h | 10 ++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 170681b..090576b 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -175,7 +175,6 @@ static void evdev_queue_syn_dropped(struct evdev_client *client) static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid) { - unsigned long flags; unsigned int clk_type; switch (clkid) { @@ -193,21 +192,29 @@ static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid) return -EINVAL; } - if (client->clk_type != clk_type) { + if (client->clk_type != clk_type) client->clk_type = clk_type; - /* - * Flush pending events and queue SYN_DROPPED event, - * but only if the queue is not empty. - */ - spin_lock_irqsave(&client->buffer_lock, flags); + return 0; +} - if (client->head != client->tail) { - client->packet_head = client->head = client->tail; - __evdev_queue_syn_dropped(client); - } +static int evdev_set_if_type(struct evdev_client *client, unsigned int if_type) +{ + if (client->if_type == if_type) + return 0; - spin_unlock_irqrestore(&client->buffer_lock, flags); + switch (if_type) { + case EVDEV_LEGACY: + client->if_type = EV_IF_LEGACY; + break; + case EVDEV_RAW: + client->if_type = EV_IF_RAW; + break; + case EVDEV_COMPOSITE: + client->if_type = EV_IF_COMPOSITE; + break; + default: + return -EINVAL; } return 0; @@ -1046,6 +1053,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, int __user *ip = (int __user *)p; unsigned int i, t, u, v; unsigned int size; + int if_type; int error; /* First we check for fixed-length commands */ @@ -1144,6 +1152,13 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, case EVIOCSKEYCODE_V2: return evdev_handle_set_keycode_v2(dev, p); + case EVIOCSIFTYPE: + if (get_user(if_type, ip)) + return -EFAULT; + + return evdev_set_if_type(client, if_type); + case EVIOCGIFTYPE: + return put_user(client->if_type, ip); } size = _IOC_SIZE(cmd); diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index 79b35ff..9ae5243 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -234,6 +234,16 @@ struct input_mask { #define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */ +#define EVIOCSIFTYPE _IOW('E', 0xa1, int) /* Set if_type */ +#define EVIOCGIFTYPE _IOR('E', 0xa2, int) /* Get if_type */ + +/* + * evdev interface type + */ +#define EVDEV_LEGACY 0x00 +#define EVDEV_RAW 0x01 +#define EVDEV_COMPOSITE 0x02 + /* * IDs. */