aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorChristian Borntraeger <borntraeger@de.ibm.com>2008-11-25 07:36:26 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-12-29 17:56:10 -0500
commitc29834584ea4eafccf2f62a0b8a32e64f792044c (patch)
tree296533011a14c83ad20e02c89dc391f93cf12fcd /drivers/char
parent29f9f12ec737af62835124e4a8bdb9de631f04dd (diff)
virtio_console: support console resizing
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>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/char/virtio_console.c30
2 files changed, 30 insertions, 1 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index fb57f67bb427..0587b66d6fc7 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -695,6 +695,7 @@ void hvc_resize(struct hvc_struct *hp, struct winsize ws)
695 hp->ws = ws; 695 hp->ws = ws;
696 schedule_work(&hp->tty_resize); 696 schedule_work(&hp->tty_resize);
697} 697}
698EXPORT_SYMBOL_GPL(hvc_resize);
698 699
699/* 700/*
700 * This kthread is either polling or interrupt driven. This is determined by 701 * This kthread is either polling or interrupt driven. This is determined by
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 3fb0d2c88ba5..ff6f5a4b58fb 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -138,12 +138,33 @@ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
138} 138}
139 139
140/* 140/*
141 * virtio console configuration. This supports:
142 * - console resize
143 */
144static void virtcons_apply_config(struct virtio_device *dev)
145{
146 struct winsize ws;
147
148 if (virtio_has_feature(dev, VIRTIO_CONSOLE_F_SIZE)) {
149 dev->config->get(dev,
150 offsetof(struct virtio_console_config, cols),
151 &ws.ws_col, sizeof(u16));
152 dev->config->get(dev,
153 offsetof(struct virtio_console_config, rows),
154 &ws.ws_row, sizeof(u16));
155 hvc_resize(hvc, ws);
156 }
157}
158
159/*
141 * we support only one console, the hvc struct is a global var 160 * we support only one console, the hvc struct is a global var
142 * There is no need to do anything 161 * We set the configuration at this point, since we now have a tty
143 */ 162 */
144static int notifier_add_vio(struct hvc_struct *hp, int data) 163static int notifier_add_vio(struct hvc_struct *hp, int data)
145{ 164{
146 hp->irq_requested = 1; 165 hp->irq_requested = 1;
166 virtcons_apply_config(vdev);
167
147 return 0; 168 return 0;
148} 169}
149 170
@@ -234,11 +255,18 @@ static struct virtio_device_id id_table[] = {
234 { 0 }, 255 { 0 },
235}; 256};
236 257
258static unsigned int features[] = {
259 VIRTIO_CONSOLE_F_SIZE,
260};
261
237static struct virtio_driver virtio_console = { 262static struct virtio_driver virtio_console = {
263 .feature_table = features,
264 .feature_table_size = ARRAY_SIZE(features),
238 .driver.name = KBUILD_MODNAME, 265 .driver.name = KBUILD_MODNAME,
239 .driver.owner = THIS_MODULE, 266 .driver.owner = THIS_MODULE,
240 .id_table = id_table, 267 .id_table = id_table,
241 .probe = virtcons_probe, 268 .probe = virtcons_probe,
269 .config_changed = virtcons_apply_config,
242}; 270};
243 271
244static int __init init(void) 272static int __init init(void)