Commit 8c3c283e authored by Olaf Hering's avatar Olaf Hering Committed by Dmitry Torokhov

Input: xen-kbdfront - advertise either absolute or relative coordinates

A virtualized display device is usually viewed with the vncviewer
application, either by 'xm vnc domU' or with vncviewer localhost:port.
vncviewer and the RFB protocol provides absolute coordinates to the
virtual display. These coordinates are either passed through to a PV
guest or converted to relative coordinates for a HVM guest.

A PV guest receives these coordinates and passes them to the kernels
evdev driver. There it can be picked up by applications such as the
xorg-input drivers. Using absolute coordinates avoids issues such as
guest mouse pointer not tracking host mouse pointer due to wrong mouse
acceleration settings in the guests X display.

Advertise either absolute or relative coordinates to the input system
and the evdev driver, depending on what dom0 provides. The xorg-input
driver prefers relative coordinates even if a devices provides both.
Signed-off-by: default avatarOlaf Hering <olaf@aepfle.de>
Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 53a2b81c
...@@ -110,7 +110,7 @@ static irqreturn_t input_handler(int rq, void *dev_id) ...@@ -110,7 +110,7 @@ static irqreturn_t input_handler(int rq, void *dev_id)
static int __devinit xenkbd_probe(struct xenbus_device *dev, static int __devinit xenkbd_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id) const struct xenbus_device_id *id)
{ {
int ret, i; int ret, i, abs;
struct xenkbd_info *info; struct xenkbd_info *info;
struct input_dev *kbd, *ptr; struct input_dev *kbd, *ptr;
...@@ -128,6 +128,11 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, ...@@ -128,6 +128,11 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
if (!info->page) if (!info->page)
goto error_nomem; goto error_nomem;
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0)
abs = 0;
if (abs)
xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1");
/* keyboard */ /* keyboard */
kbd = input_allocate_device(); kbd = input_allocate_device();
if (!kbd) if (!kbd)
...@@ -137,11 +142,12 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, ...@@ -137,11 +142,12 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
kbd->id.bustype = BUS_PCI; kbd->id.bustype = BUS_PCI;
kbd->id.vendor = 0x5853; kbd->id.vendor = 0x5853;
kbd->id.product = 0xffff; kbd->id.product = 0xffff;
kbd->evbit[0] = BIT(EV_KEY);
__set_bit(EV_KEY, kbd->evbit);
for (i = KEY_ESC; i < KEY_UNKNOWN; i++) for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
set_bit(i, kbd->keybit); __set_bit(i, kbd->keybit);
for (i = KEY_OK; i < KEY_MAX; i++) for (i = KEY_OK; i < KEY_MAX; i++)
set_bit(i, kbd->keybit); __set_bit(i, kbd->keybit);
ret = input_register_device(kbd); ret = input_register_device(kbd);
if (ret) { if (ret) {
...@@ -160,12 +166,20 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, ...@@ -160,12 +166,20 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev,
ptr->id.bustype = BUS_PCI; ptr->id.bustype = BUS_PCI;
ptr->id.vendor = 0x5853; ptr->id.vendor = 0x5853;
ptr->id.product = 0xfffe; ptr->id.product = 0xfffe;
ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
if (abs) {
__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);
} else {
input_set_capability(ptr, EV_REL, REL_X);
input_set_capability(ptr, EV_REL, REL_Y);
}
input_set_capability(ptr, EV_REL, REL_WHEEL);
__set_bit(EV_KEY, ptr->evbit);
for (i = BTN_LEFT; i <= BTN_TASK; i++) for (i = BTN_LEFT; i <= BTN_TASK; i++)
set_bit(i, ptr->keybit); __set_bit(i, ptr->keybit);
ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
ret = input_register_device(ptr); ret = input_register_device(ptr);
if (ret) { if (ret) {
...@@ -272,7 +286,7 @@ static void xenkbd_backend_changed(struct xenbus_device *dev, ...@@ -272,7 +286,7 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
enum xenbus_state backend_state) enum xenbus_state backend_state)
{ {
struct xenkbd_info *info = dev_get_drvdata(&dev->dev); struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
int ret, val; int val;
switch (backend_state) { switch (backend_state) {
case XenbusStateInitialising: case XenbusStateInitialising:
...@@ -285,16 +299,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev, ...@@ -285,16 +299,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
case XenbusStateInitWait: case XenbusStateInitWait:
InitWait: InitWait:
ret = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-abs-pointer", "%d", &val);
if (ret < 0)
val = 0;
if (val) {
ret = xenbus_printf(XBT_NIL, info->xbdev->nodename,
"request-abs-pointer", "1");
if (ret)
pr_warning("can't request abs-pointer\n");
}
xenbus_switch_state(dev, XenbusStateConnected); xenbus_switch_state(dev, XenbusStateConnected);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment