From: Tim Sell <timothy.s...@unisys.com>

Previously, we used a hack to determine the max x,y resolution of the
visor virtual mouse: we just looked at the resolution of the
first-registered framebuffer device, using the currently-valid assumption
that in a Unisys s-Par guest environment the video will be provided by an
efifb framebuffer device.

This hack has been removed, by instead determining the default mouse
resolution by looking at fields within the visor mouse channel memory,
mouse.x_resolution and mouse.y_resolution.  If these fields are 0, a
default resolution of 1024x768 is assumed.  Note that in current
implementations, mouse.x_resolution and mouse.y_resolution are always just
initialized to 0 by the back-end, and only 1024x768 is supported, but
coding it this way will allow other resolutions to work in the future.

Signed-off-by: Tim Sell <timothy.s...@unisys.com>
Signed-off-by: Benjamin Romer <benjamin.ro...@unisys.com>

---
v2: the patch was resubmitted.
---
 drivers/staging/unisys/visorinput/Kconfig      |  2 +-
 drivers/staging/unisys/visorinput/visorinput.c | 63 +++++++++++++++++++++-----
 2 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/unisys/visorinput/Kconfig 
b/drivers/staging/unisys/visorinput/Kconfig
index d83deb4..1c5a072 100644
--- a/drivers/staging/unisys/visorinput/Kconfig
+++ b/drivers/staging/unisys/visorinput/Kconfig
@@ -4,7 +4,7 @@
 
 config UNISYS_VISORINPUT
        tristate "Unisys visorinput driver"
-       depends on UNISYSSPAR && UNISYS_VISORBUS && FB
+       depends on UNISYSSPAR && UNISYS_VISORBUS
        ---help---
        If you say Y here, you will enable the Unisys visorinput driver.
 
diff --git a/drivers/staging/unisys/visorinput/visorinput.c 
b/drivers/staging/unisys/visorinput/visorinput.c
index 238a132..4620a49 100644
--- a/drivers/staging/unisys/visorinput/visorinput.c
+++ b/drivers/staging/unisys/visorinput/visorinput.c
@@ -47,8 +47,38 @@
 #define SPAR_MOUSE_CHANNEL_PROTOCOL_UUID_STR \
        "addf07d4-94a9-46e2-81c3-61abcdbdbd87"
 
-#define PIXELS_ACROSS_DEFAULT  800
-#define PIXELS_DOWN_DEFAULT    600
+/* header of keyboard/mouse channels */
+struct spar_input_channel_protocol {
+       struct channel_header channel_header;
+       u32 n_input_reports;
+       union {
+               struct {
+                       u16 x_resolution;
+                       u16 y_resolution;
+               } mouse;
+               struct {
+                       u32 flags;
+               } keyboard;
+       };
+} __packed;
+
+#define sizeofmemb(TYPE, MEMBER) sizeof(((TYPE *)0)->MEMBER)
+
+static unsigned read_input_channel_uint(struct visor_device *dev,
+                                       unsigned offset, unsigned size)
+{
+       unsigned v = 0;
+
+       if (visorbus_read_channel(dev, offset, &v, size)) {
+               dev_warn(&dev->device,
+                        "failed to read channel int at offset %u\n", offset);
+               return 0;
+       }
+       return v;
+}
+
+#define PIXELS_ACROSS_DEFAULT  1024
+#define PIXELS_DOWN_DEFAULT    768
 #define KEYCODE_TABLE_BYTES    256
 
 enum visorinput_device_type {
@@ -298,12 +328,11 @@ register_client_keyboard(void *devdata,  /* opaque on 
purpose */
 }
 
 static struct input_dev *
-register_client_mouse(void *devdata /* opaque on purpose */)
+register_client_mouse(void *devdata /* opaque on purpose */,
+                     unsigned xres, unsigned yres)
 {
        int error;
        struct input_dev *visorinput_dev = NULL;
-       int xres, yres;
-       struct fb_info *fb0;
 
        visorinput_dev = input_allocate_device();
        if (!visorinput_dev)
@@ -321,14 +350,10 @@ register_client_mouse(void *devdata /* opaque on purpose 
*/)
        set_bit(BTN_RIGHT, visorinput_dev->keybit);
        set_bit(BTN_MIDDLE, visorinput_dev->keybit);
 
-       if (registered_fb[0]) {
-               fb0 = registered_fb[0];
-               xres = fb0->var.xres_virtual;
-               yres = fb0->var.yres_virtual;
-       } else {
+       if (xres == 0)
                xres = PIXELS_ACROSS_DEFAULT;
+       if (yres == 0)
                yres = PIXELS_DOWN_DEFAULT;
-       }
        input_set_abs_params(visorinput_dev, ABS_X, 0, xres, 0, 0);
        input_set_abs_params(visorinput_dev, ABS_Y, 0, yres, 0, 0);
 
@@ -381,6 +406,7 @@ devdata_create(struct visor_device *dev, enum 
visorinput_device_type devtype)
 {
        struct visorinput_devdata *devdata = NULL;
        unsigned int extra_bytes = 0;
+       unsigned xres, yres;
 
        if (devtype == visorinput_keyboard)
                /* allocate room for devdata->keycode_table, filled in below */
@@ -408,7 +434,20 @@ devdata_create(struct visor_device *dev, enum 
visorinput_device_type devtype)
                        goto cleanups_register;
                break;
        case visorinput_mouse:
-               devdata->visorinput_dev = register_client_mouse(devdata);
+               xres = read_input_channel_uint
+                       (dev,
+                        offsetof(struct spar_input_channel_protocol,
+                                 mouse.x_resolution),
+                        sizeofmemb(struct spar_input_channel_protocol,
+                                   mouse.x_resolution));
+               yres = read_input_channel_uint
+                       (dev,
+                        offsetof(struct spar_input_channel_protocol,
+                                 mouse.y_resolution),
+                        sizeofmemb(struct spar_input_channel_protocol,
+                                   mouse.y_resolution));
+               devdata->visorinput_dev =
+                       register_client_mouse(devdata, xres, yres);
                if (!devdata->visorinput_dev)
                        goto cleanups_register;
                break;
-- 
2.5.0

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to