tablet: Applying the screen size in the driver probing.
authorjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 14 Oct 2015 06:56:34 +0000 (15:56 +0900)
committerJinhyung Jo <jinhyung.jo@samsung.com>
Tue, 18 Oct 2016 07:49:00 +0000 (16:49 +0900)
The screen size is required when the initializing driver,
in order to apply the correct absolute coordinates of the mouse.

Conflicts:
drivers/maru/maru_virtio_tablet.c

Change-Id: Iaf385d1c482614595de4d82b7d5b434648b67d5d
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
(cherry picked from commit 91bac12b09a68f975a7a7800d9902918886e0751)

drivers/maru/maru_virtio_tablet.c

index 225db2408998dd9de0c1c4075e2387148ad286da..ef22ebccb64cb4b9440b09093f14720f50f9208f 100644 (file)
@@ -46,6 +46,9 @@ MODULE_DESCRIPTION("Emulator Virtio Tablet driver");
 
 #define DEVICE_NAME "virtio-tablet"
 #define MAX_BUF_COUNT 25
+#define DEFAULT_WIDTH 1920
+#define DEFAULT_HEIGHT 1080
+#define CMDLINE_VIDEO_PARAM "video=LVDS-1:"
 
 /* This structure must match the qemu definitions */
 typedef struct EmulTabletEvent {
@@ -158,6 +161,9 @@ static void vq_tablet_callback(struct virtqueue *vq)
 static int virtio_tablet_probe(struct virtio_device *vdev)
 {
        int ret = 0;
+       char *cmdline = NULL;
+       int width = 0;
+       int height = 0;
 
        printk(KERN_INFO "virtio tablet driver is probed\n");
 
@@ -207,9 +213,48 @@ static int virtio_tablet_probe(struct virtio_device *vdev)
                                | BIT_MASK(EV_ABS)
                                | BIT_MASK(EV_MSC);
 
-       /* 32767 is max size of usbdevice tablet. */
-       input_abs_set_max(vtb->idev, ABS_X, 32767);
-       input_abs_set_max(vtb->idev, ABS_Y, 32767);
+       cmdline = strstr(saved_command_line, CMDLINE_VIDEO_PARAM);
+       if (cmdline != NULL) {
+               char *tmp;
+
+               cmdline += strlen(CMDLINE_VIDEO_PARAM);
+               tmp = strsep(&cmdline, "x");
+               if (tmp != NULL) {
+                       ret = kstrtoint(tmp, 10, &width);
+                       if (ret) {
+                               printk(KERN_WARNING "cannot find the width value\n");
+                               width = 0;
+                       }
+
+                       tmp = strsep(&cmdline, "-");
+                       if (tmp != NULL) {
+                               ret = kstrtoint(tmp, 10, &height);
+                               if (ret) {
+                                       printk(KERN_WARNING "cannot find the height value\n");
+                                       height = 0;
+                               }
+                       } else {
+                               printk(KERN_WARNING "Invalid bpp separator:"
+                                               " cannot find the height value\n");
+                       }
+               } else {
+                       printk(KERN_WARNING "Invalid resolution separator: "
+                                       " cannot find the width value\n");
+               }
+       } else {
+               printk(KERN_WARNING "cannot find the video parameter(%s) "
+                               "in the kernel command line\n", CMDLINE_VIDEO_PARAM);
+       }
+
+       if (!width || !height) {
+               width = DEFAULT_WIDTH;
+               height = DEFAULT_HEIGHT;
+               printk(KERN_WARNING "cannot find the width or height, "
+                       "use default values %dx%d\n", width, height);
+       }
+
+       input_set_abs_params(vtb->idev, ABS_X, 0, width, 0, 0);
+       input_set_abs_params(vtb->idev, ABS_Y, 0, height, 0, 0);
 
        set_bit(BTN_LEFT, vtb->idev->keybit);
        set_bit(BTN_RIGHT, vtb->idev->keybit);