aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/char/virtio_console.c30
-rw-r--r--include/linux/virtio_console.h11
3 files changed, 41 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)
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h
index 19a0da0dba41..7615ffcdd555 100644
--- a/include/linux/virtio_console.h
+++ b/include/linux/virtio_console.h
@@ -7,6 +7,17 @@
7/* The ID for virtio console */ 7/* The ID for virtio console */
8#define VIRTIO_ID_CONSOLE 3 8#define VIRTIO_ID_CONSOLE 3
9 9
10/* Feature bits */
11#define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */
12
13struct virtio_console_config {
14 /* colums of the screens */
15 __u16 cols;
16 /* rows of the screens */
17 __u16 rows;
18} __attribute__((packed));
19
20
10#ifdef __KERNEL__ 21#ifdef __KERNEL__
11int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)); 22int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int));
12#endif /* __KERNEL__ */ 23#endif /* __KERNEL__ */