From 644f66bf5d09f98d1da7a6bcec6bd9ce795f868c Mon Sep 17 00:00:00 2001 From: Daniel P. Berrangé Date: Tue, 9 Mar 2021 15:58:04 +0000 Subject: hw/input: expand trace info reported for ps2 device It is interesting to know if the PS2 keyboard is in translated mode, and which of the three scancode sets are in use. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé Message-Id: <20210309155804.306051-1-berrange@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw/input/ps2.c') diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 72cdb80ae1..5352e417a4 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -293,7 +293,8 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src, qcode = qemu_input_key_value_to_qcode(key->key); mod = ps2_modifier_bit(qcode); - trace_ps2_keyboard_event(s, qcode, key->down, mod, s->modifiers); + trace_ps2_keyboard_event(s, qcode, key->down, mod, + s->modifiers, s->scancode_set, s->translate); if (key->down) { s->modifiers |= mod; } else { -- cgit v1.2.3-55-g7522 From 76968101f549fb6bb51b4bdea65e8a48307c765d Mon Sep 17 00:00:00 2001 From: Volker Rümelin Date: Tue, 25 May 2021 20:14:30 +0200 Subject: ps2: fix mouse stream corruption Commit 7abe7eb294 "ps2: Fix mouse stream corruption due to lost data" added code to avoid mouse stream corruptions but the calculation of the needed free queue size was wrong. Fix this. To reproduce, open a text file with the vim 7.3 32 bit for DOS exe- cutable in a FreeDOS client started with -display sdl and move the mouse around for a few seconds. You will quickly see erratic mouse movements and unexpected mouse clicks. CuteMouse (ctmouse.exe) in FreeDOS doesn't try to re-sync the mouse stream. Fixes: 7abe7eb294 ("ps2: Fix mouse stream corruption due to lost data") Signed-off-by: Volker Rümelin Message-Id: <20210525181441.27768-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw/input/ps2.c') diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 5352e417a4..7a3fb2b9f6 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -646,7 +646,8 @@ void ps2_keyboard_set_translation(void *opaque, int mode) static int ps2_mouse_send_packet(PS2MouseState *s) { - const int needed = 3 + (s->mouse_type - 2); + /* IMPS/2 and IMEX send 4 bytes, PS2 sends 3 bytes */ + const int needed = s->mouse_type ? 4 : 3; unsigned int b; int dx1, dy1, dz1; -- cgit v1.2.3-55-g7522 From 7704bb02dd73070b218fb091cdda79679dab2b8f Mon Sep 17 00:00:00 2001 From: Volker Rümelin Date: Tue, 25 May 2021 20:14:31 +0200 Subject: ps2: don't raise an interrupt if queue is full ps2_queue() behaves differently than the very similar functions ps2_queue_2() to ps2_queue_4(). The first one calls update_irq() even if the queue is full, the others don't. Change ps2_queue() to be consistent with the others. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Volker Rümelin Message-Id: <20210525181441.27768-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hw/input/ps2.c') diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 7a3fb2b9f6..7c7a158e31 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -212,6 +212,10 @@ void ps2_raise_irq(PS2State *s) void ps2_queue(PS2State *s, int b) { + if (PS2_QUEUE_SIZE - s->queue.count < 1) { + return; + } + ps2_queue_noirq(s, b); s->update_irq(s->update_arg, 1); } -- cgit v1.2.3-55-g7522 From cec3252416bb76d3c5cee178825a6321950cedec Mon Sep 17 00:00:00 2001 From: Volker Rümelin Date: Tue, 25 May 2021 20:14:32 +0200 Subject: ps2: don't deassert irq twice if queue is empty Don't deassert the irq twice if the queue is empty. While the second deassertion doesn't do any harm, it's unnecessary. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Volker Rümelin Message-Id: <20210525181441.27768-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'hw/input/ps2.c') diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 7c7a158e31..5cf95b4dd3 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -520,7 +520,9 @@ uint32_t ps2_read_data(PS2State *s) /* reading deasserts IRQ */ s->update_irq(s->update_arg, 0); /* reassert IRQs if data left */ - s->update_irq(s->update_arg, q->count != 0); + if (q->count) { + s->update_irq(s->update_arg, 1); + } } return val; } -- cgit v1.2.3-55-g7522 From 96376ab154cfb7a8f0b985e26db5b0074b86c2ee Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Thu, 13 May 2021 19:12:44 +0200 Subject: hw/input/ps2: Use ps2_raise_irq() instead of open coding it Inspired-by: Volker Rümelin Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Volker Rümelin Reviewed-by: Bin Meng Message-Id: <20210513171244.3940519-1-f4bug@amsat.org> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hw/input/ps2.c') diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 5cf95b4dd3..8dd482c1f6 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -217,7 +217,7 @@ void ps2_queue(PS2State *s, int b) } ps2_queue_noirq(s, b); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } void ps2_queue_2(PS2State *s, int b1, int b2) @@ -228,7 +228,7 @@ void ps2_queue_2(PS2State *s, int b1, int b2) ps2_queue_noirq(s, b1); ps2_queue_noirq(s, b2); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } void ps2_queue_3(PS2State *s, int b1, int b2, int b3) @@ -240,7 +240,7 @@ void ps2_queue_3(PS2State *s, int b1, int b2, int b3) ps2_queue_noirq(s, b1); ps2_queue_noirq(s, b2); ps2_queue_noirq(s, b3); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4) @@ -253,7 +253,7 @@ void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4) ps2_queue_noirq(s, b2); ps2_queue_noirq(s, b3); ps2_queue_noirq(s, b4); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } /* keycode is the untranslated scancode in the current scancode set. */ -- cgit v1.2.3-55-g7522