]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
virtio_console: support console resizing
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 25 Nov 2008 12:36:26 +0000 (13:36 +0100)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 29 Dec 2008 22:56:10 +0000 (09:26 +1030)
this patch uses the new hvc callback hvc_resize to set the window size
which allows to change the tty size of hvc_console via a hvc_resize
function.

I have added a new feature bit VIRTIO_CONSOLE_F_SIZE. The driver will
change the window size on tty open and via the config_changed callback
of the transport. Currently lguest and kvm_s390 have not implemented this
callback, but the callback can be implemented at a later point in time.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/hvc_console.c
drivers/char/virtio_console.c
include/linux/virtio_console.h

index fb57f67bb427fb86e23e9b6c723ba3fcae467ea9..0587b66d6fc7070225e7f493517cc30cac11cfdc 100644 (file)
@@ -695,6 +695,7 @@ void hvc_resize(struct hvc_struct *hp, struct winsize ws)
        hp->ws = ws;
        schedule_work(&hp->tty_resize);
 }
+EXPORT_SYMBOL_GPL(hvc_resize);
 
 /*
  * This kthread is either polling or interrupt driven.  This is determined by
index 3fb0d2c88ba5fd3252bf7d773c8ecdaafc9de395..ff6f5a4b58fb5acd25622ad4fdd1b1a9c45b15f0 100644 (file)
@@ -137,13 +137,34 @@ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
        return hvc_instantiate(0, 0, &virtio_cons);
 }
 
+/*
+ * virtio console configuration. This supports:
+ * - console resize
+ */
+static void virtcons_apply_config(struct virtio_device *dev)
+{
+       struct winsize ws;
+
+       if (virtio_has_feature(dev, VIRTIO_CONSOLE_F_SIZE)) {
+               dev->config->get(dev,
+                                offsetof(struct virtio_console_config, cols),
+                                &ws.ws_col, sizeof(u16));
+               dev->config->get(dev,
+                                offsetof(struct virtio_console_config, rows),
+                                &ws.ws_row, sizeof(u16));
+               hvc_resize(hvc, ws);
+       }
+}
+
 /*
  * we support only one console, the hvc struct is a global var
- * There is no need to do anything
+ * We set the configuration at this point, since we now have a tty
  */
 static int notifier_add_vio(struct hvc_struct *hp, int data)
 {
        hp->irq_requested = 1;
+       virtcons_apply_config(vdev);
+
        return 0;
 }
 
@@ -234,11 +255,18 @@ static struct virtio_device_id id_table[] = {
        { 0 },
 };
 
+static unsigned int features[] = {
+       VIRTIO_CONSOLE_F_SIZE,
+};
+
 static struct virtio_driver virtio_console = {
+       .feature_table = features,
+       .feature_table_size = ARRAY_SIZE(features),
        .driver.name =  KBUILD_MODNAME,
        .driver.owner = THIS_MODULE,
        .id_table =     id_table,
        .probe =        virtcons_probe,
+       .config_changed = virtcons_apply_config,
 };
 
 static int __init init(void)
index 19a0da0dba41203a59d5d2bce2762d2c2b78a240..7615ffcdd555cb2d3b1fa80b5f380c492881b394 100644 (file)
@@ -7,6 +7,17 @@
 /* The ID for virtio console */
 #define VIRTIO_ID_CONSOLE      3
 
+/* Feature bits */
+#define VIRTIO_CONSOLE_F_SIZE  0       /* Does host provide console size? */
+
+struct virtio_console_config {
+       /* colums of the screens */
+       __u16 cols;
+       /* rows of the screens */
+       __u16 rows;
+} __attribute__((packed));
+
+
 #ifdef __KERNEL__
 int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int));
 #endif /* __KERNEL__ */