All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: Gerd Hoffmann <kraxel@suse.de>,
	Xen devel list <xen-devel@lists.xensource.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: Re: [patch] pvfb: Split mouse and keyboard into separate devices.
Date: Sat, 3 Feb 2007 00:28:25 +0000	[thread overview]
Message-ID: <20070203002825.GH18218@redhat.com> (raw)
In-Reply-To: <C1E92F6A.8CB6%Keir.Fraser@cl.cam.ac.uk>

[-- Attachment #1: Type: text/plain, Size: 3481 bytes --]

On Fri, Feb 02, 2007 at 06:11:54PM +0000, Keir Fraser wrote:
> On 2/2/07 16:29, "Gerd Hoffmann" <kraxel@suse.de> wrote:
> 
> >> I guess I'll wait for this before applying the patch then.
> > 
> > With Xorg 7.2, this patch, and the device id patch on top you can add
> > this ...
> > 
> > Section "InputDevice"
> >   Driver        "evdev"
> >   Identifier    "xenptr"
> >   Option        "SendCoreEvents" "true"
> >   Option        "vendor"        "0x5853"
> >   Option        "product"       "0x0003"
> > EndSection
> > 
> > ... as additional (to the default /dev/input/mice) input device.  The
> > new input device must also be added to the serverlayout section.
> > WorksForMe[tm].
> 
> The complaint is that it doesn't work out of the box with current Xorg. If
> that is a showstopper (it certainly is at the very least very undesirable!)
> then it doesn't matter how simple the required config change is -- if any
> change is required at all then the patch is untenable.
> 
> How hard would it be to contineu to provide the combined device as well as
> the new split-out pointer device?

I've just hacked up such a version and it appears to work fine - although
you need a slightly more complicated Xorg config to get the absolute
pointer working.

So what the patch does is this:

  - One input device supplies both mouse & keyboard events - this is 
    basically same as current PVFB setup (appears /dev/input/event0)
  - A second device supplies only mouse events (/dev/input/event1)

So with a default Xorg config, X works just as before - the server sees
the relative co-ords via its default 'mouse' driver.

If we want to explicitly configure absolute co-ords, we first define an
input device for /dev/input/event1 - this deals with the pure mouse
only stream of absolute coords. The evdev driver ensures that the events
from event1 no longer get reported via the unified mouse channel. Of 
course we still have the relative coords coming in on event0 though 
and thus into X via the 'mouse' driver which mess things up. So we have
a second 'void' input device which explicitly kills off the default
mouse handling. The result, mouse events only get processed from event1

Section "ServerLayout"
   ...snip...
       InputDevice    "Mouse0" "CorePointer"
       InputDevice    "KillDefaultMouse"
EndSection

Section "InputDevice"
       Identifier  "Mouse0"
       Driver      "evdev"
       Option      "Device" "/dev/input/event1"
EndSection

Section "InputDevice"
       Identifier  "KillDefaultMouse"
       Driver      "void"
EndSection


The attached patch was against Gerd's first version of the patch, so don't
have his other fixes in yet. But it shows we can setup the input devices
such that existing relative coords work with no config changes, while allowing 
people to opt in to using absolute coords only via a xorg.conf change. 
We probably want to adjust the naming again such that event0 is called 
'Xen Virtual Keyboard/Mouse' while event1 is just called 'Xen Virtual Mouse".
This gives compatability with original xenkbd driver for programs like kudzu 
which might be doing  device lookups based on the current naming.

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-abs-mouse.patch --]
[-- Type: text/plain, Size: 5475 bytes --]

diff -r 2e80cd715047 linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c	Thu Feb 01 11:42:50 2007 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c	Fri Feb 02 19:17:00 2007 -0500
@@ -29,8 +29,10 @@
 
 struct xenkbd_info
 {
-	struct input_dev *dev;
+	struct input_dev *kbd;
+	struct input_dev *ptr;
 	struct xenkbd_page *page;
+	unsigned evtchn;
 	int irq;
 	struct xenbus_device *xbdev;
 };
@@ -60,22 +62,30 @@ static irqreturn_t input_handler(int rq,
 
 		switch (event->type) {
 		case XENKBD_TYPE_MOTION:
-			input_report_rel(info->dev, REL_X, event->motion.rel_x);
-			input_report_rel(info->dev, REL_Y, event->motion.rel_y);
+			input_report_rel(info->ptr, REL_X, event->motion.rel_x);
+			input_report_rel(info->ptr, REL_Y, event->motion.rel_y);
+			input_sync(info->ptr);
+			input_report_rel(info->kbd, REL_X, event->motion.rel_x);
+			input_report_rel(info->kbd, REL_Y, event->motion.rel_y);
+			input_sync(info->kbd);
 			break;
 		case XENKBD_TYPE_KEY:
-			input_report_key(info->dev, event->key.keycode, event->key.pressed);
+			input_report_key(info->kbd, event->key.keycode, event->key.pressed);
+			input_sync(info->kbd);
 			break;
 		case XENKBD_TYPE_POS:
-			input_report_abs(info->dev, ABS_X, event->pos.abs_x);
-			input_report_abs(info->dev, ABS_Y, event->pos.abs_y);
+			input_report_abs(info->ptr, ABS_X, event->pos.abs_x);
+			input_report_abs(info->ptr, ABS_Y, event->pos.abs_y);
+			input_sync(info->ptr);
+			input_report_abs(info->kbd, ABS_X, event->pos.abs_x);
+			input_report_abs(info->kbd, ABS_Y, event->pos.abs_y);
+			input_sync(info->kbd);
 			break;
 		}
 	}
-	input_sync(info->dev);
 	mb();			/* ensure we got ring contents */
 	page->in_cons = cons;
-	notify_remote_via_irq(info->irq);
+	notify_remote_via_evtchn(info->evtchn);
 
 	return IRQ_HANDLED;
 }
@@ -85,7 +95,7 @@ int __devinit xenkbd_probe(struct xenbus
 {
 	int ret, i;
 	struct xenkbd_info *info;
-	struct input_dev *input_dev;
+	struct input_dev *kbd, *ptr;
 
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
@@ -101,32 +111,50 @@ int __devinit xenkbd_probe(struct xenbus
 	info->page->in_cons = info->page->in_prod = 0;
 	info->page->out_cons = info->page->out_prod = 0;
 
-	input_dev = input_allocate_device();
-	if (!input_dev)
+	kbd = input_allocate_device();
+	ptr = input_allocate_device();
+	if (!kbd || !ptr)
 		goto error_nomem;
 
-	input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
-	input_dev->keybit[LONG(BTN_MOUSE)]
+	ptr->evbit[0] = BIT(EV_REL) | BIT(EV_ABS);
+	ptr->keybit[LONG(BTN_MOUSE)]
 		= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
 	/* TODO additional buttons */
-	input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
-
+	ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+
+	kbd->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
+	kbd->keybit[LONG(BTN_MOUSE)]
+		= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+	/* TODO additional buttons */
+	kbd->relbit[0] = BIT(REL_X) | BIT(REL_Y);
 	/* FIXME not sure this is quite right */
 	for (i = 0; i < 256; i++)
-		set_bit(i, input_dev->keybit);
-
-	input_dev->name = "Xen Virtual Keyboard/Mouse";
-
-	input_set_abs_params(input_dev, ABS_X, 0, XENFB_WIDTH, 0, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
-
-	ret = input_register_device(input_dev);
-	if (ret) {
-		input_free_device(input_dev);
-		xenbus_dev_fatal(dev, ret, "input_register_device");
+		set_bit(i, kbd->keybit);
+
+	kbd->name = "Xen Virtual Keyboard";
+	ptr->name = "Xen Virtual Touchscreen";
+
+	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(kbd, ABS_X, 0, XENFB_WIDTH, 0, 0);
+	input_set_abs_params(kbd, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
+
+	ret = input_register_device(kbd);
+	if (ret) {
+		input_free_device(kbd);
+		input_free_device(ptr);
+		xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
 		goto error;
 	}
-	info->dev = input_dev;
+	info->kbd = kbd;
+
+	ret = input_register_device(ptr);
+	if (ret) {
+		input_free_device(ptr);
+		xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
+		goto error;
+	}
+	info->ptr = ptr;
 
 	ret = xenkbd_connect_backend(dev, info);
 	if (ret < 0)
@@ -155,7 +183,8 @@ static int xenkbd_remove(struct xenbus_d
 	struct xenkbd_info *info = dev->dev.driver_data;
 
 	xenkbd_disconnect_backend(info);
-	input_unregister_device(info->dev);
+	input_unregister_device(info->kbd);
+	input_unregister_device(info->ptr);
 	free_page((unsigned long)info->page);
 	kfree(info);
 	return 0;
@@ -167,11 +196,14 @@ static int xenkbd_connect_backend(struct
 	int ret;
 	struct xenbus_transaction xbt;
 
-	ret = bind_listening_port_to_irqhandler(
-		dev->otherend_id, input_handler, 0, "xenkbd", info);
+	ret = xenbus_alloc_evtchn(dev, &info->evtchn);
+	if (ret)
+		return ret;
+	ret = bind_evtchn_to_irqhandler(info->evtchn, input_handler, 0,
+					"xenkbd", info);
 	if (ret < 0) {
-		xenbus_dev_fatal(dev, ret,
-				 "bind_listening_port_to_irqhandler");
+		xenbus_free_evtchn(dev, info->evtchn);
+		xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
 		return ret;
 	}
 	info->irq = ret;
@@ -187,7 +219,7 @@ static int xenkbd_connect_backend(struct
 	if (ret)
 		goto error_xenbus;
 	ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
-			    irq_to_evtchn_port(info->irq));
+			    info->evtchn);
 	if (ret)
 		goto error_xenbus;
 	ret = xenbus_transaction_end(xbt, 0);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2007-02-03  0:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-01 10:59 [patch] pvfb: Split mouse and keyboard into separate devices Gerd Hoffmann
2007-02-01 13:15 ` Markus Armbruster
2007-02-01 13:47   ` Gerd Hoffmann
2007-02-01 17:37 ` Markus Armbruster
2007-02-01 18:05   ` Daniel P. Berrange
2007-02-02  8:39     ` Gerd Hoffmann
2007-02-02 15:25       ` Keir Fraser
2007-02-02 16:29         ` Gerd Hoffmann
2007-02-02 18:11           ` Keir Fraser
2007-02-03  0:28             ` Daniel P. Berrange [this message]
2007-02-03  3:51               ` Daniel P. Berrange
2007-02-05  9:20                 ` Gerd Hoffmann
2007-02-05 14:19                 ` Gerd Hoffmann
2007-02-05  9:10               ` Gerd Hoffmann
2007-02-05 20:55                 ` Daniel P. Berrange
2007-02-06  8:48                   ` Gerd Hoffmann
2007-02-06 13:45                     ` Daniel P. Berrange
2007-02-06 15:05                       ` Gerd Hoffmann
2007-02-06 18:40                     ` Markus Armbruster
2007-02-07  9:35                       ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070203002825.GH18218@redhat.com \
    --to=berrange@redhat.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=armbru@redhat.com \
    --cc=kraxel@suse.de \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.