From patchwork Mon Jan 30 15:10:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 9545585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6FAD1604A8 for ; Mon, 30 Jan 2017 15:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6088D20243 for ; Mon, 30 Jan 2017 15:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54E482811E; Mon, 30 Jan 2017 15:11:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E88492816B for ; Mon, 30 Jan 2017 15:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752428AbdA3PK7 (ORCPT ); Mon, 30 Jan 2017 10:10:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:40410 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753519AbdA3PK6 (ORCPT ); Mon, 30 Jan 2017 10:10:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 639AFAB9A; Mon, 30 Jan 2017 15:10:56 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, xen-devel@lists.xenproject.org Cc: dmitry.torokhov@gmail.com, Juergen Gross Subject: [PATCH v3] xen, input: try to read screen resolution for xen-kbdfront Date: Mon, 30 Jan 2017 16:10:52 +0100 Message-Id: <20170130151052.20296-1-jgross@suse.com> X-Mailer: git-send-email 2.10.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using the default resolution of 800*600 for the pointing device of xen-kbdfront try to read the resolution of the (virtual) framebuffer device. Use the default as fallback only. Signed-off-by: Juergen Gross --- V3: add case of late framebuffer registration (Oleksandr Andrushchenko) V2: get framebuffer resolution only if CONFIG_FB (Dmitry Torokhov) --- drivers/input/misc/xen-kbdfront.c | 46 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index 3900875..9a20800 100644 --- a/drivers/input/misc/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,9 @@ struct xenkbd_info { int irq; struct xenbus_device *xbdev; char phys[32]; +#ifdef CONFIG_FB_NOTIFY + struct notifier_block nb; +#endif }; static int xenkbd_remove(struct xenbus_device *); @@ -105,10 +109,29 @@ static irqreturn_t input_handler(int rq, void *dev_id) return IRQ_HANDLED; } +#ifdef CONFIG_FB +#ifdef CONFIG_FB_NOTIFY +static int xenkbd_fb_event(struct notifier_block *self, + unsigned long action, void *data) +{ + struct xenkbd_info *info = container_of(self, struct xenkbd_info, nb); + struct fb_info *fb = registered_fb[0]; + + if (action != FB_EVENT_FB_REGISTERED || !fb) + return 0; + + input_set_abs_params(info->ptr, ABS_X, 0, fb->var.xres_virtual, 0, 0); + input_set_abs_params(info->ptr, ABS_Y, 0, fb->var.yres_virtual, 0, 0); + + return 0; +} +#endif +#endif + static int xenkbd_probe(struct xenbus_device *dev, const struct xenbus_device_id *id) { - int ret, i; + int ret, i, width, height; unsigned int abs; struct xenkbd_info *info; struct input_dev *kbd, *ptr; @@ -173,9 +196,22 @@ static int xenkbd_probe(struct xenbus_device *dev, ptr->id.product = 0xfffe; if (abs) { + width = XENFB_WIDTH; + height = XENFB_HEIGHT; +#ifdef CONFIG_FB + if (registered_fb[0]) { + width = registered_fb[0]->var.xres_virtual; + height = registered_fb[0]->var.yres_virtual; + } else { +#ifdef CONFIG_FB_NOTIFY + info->nb.notifier_call = xenkbd_fb_event; + fb_register_client(&info->nb); +#endif + } +#endif __set_bit(EV_ABS, ptr->evbit); - input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0); - input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0); + input_set_abs_params(ptr, ABS_X, 0, width, 0, 0); + input_set_abs_params(ptr, ABS_Y, 0, height, 0, 0); } else { input_set_capability(ptr, EV_REL, REL_X); input_set_capability(ptr, EV_REL, REL_Y); @@ -222,6 +258,10 @@ static int xenkbd_remove(struct xenbus_device *dev) struct xenkbd_info *info = dev_get_drvdata(&dev->dev); xenkbd_disconnect_backend(info); +#ifdef CONFIG_FB_NOTIFY + if (info->nb.notifier_call) + fb_unregister_client(&info->nb); +#endif if (info->kbd) input_unregister_device(info->kbd); if (info->ptr)