summaryrefslogtreecommitdiffstats
path: root/hw/input/ps2.c
diff options
context:
space:
mode:
authorPeter Maydell2021-05-26 16:27:20 +0200
committerPeter Maydell2021-05-26 16:27:20 +0200
commit2ab2dad01f6dc3667c0d53d2b1ba46b511031207 (patch)
treea09998e717fc03ad947da861d74f45255a49e816 /hw/input/ps2.c
parentMerge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-misc-upda... (diff)
parenthw/input/ps2: Use ps2_raise_irq() instead of open coding it (diff)
downloadqemu-2ab2dad01f6dc3667c0d53d2b1ba46b511031207.tar.gz
qemu-2ab2dad01f6dc3667c0d53d2b1ba46b511031207.tar.xz
qemu-2ab2dad01f6dc3667c0d53d2b1ba46b511031207.zip
Merge remote-tracking branch 'remotes/kraxel/tags/input-20210526-pull-request' into staging
input: a bunch of ps2 fixes. # gpg: Signature made Wed 26 May 2021 15:06:12 BST # gpg: using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/input-20210526-pull-request: hw/input/ps2: Use ps2_raise_irq() instead of open coding it pckbd: clear outport_present in outer pre_load() pckbd: remove duplicated keyboard and mouse defines pckbd: correctly disable PS/2 communication pckbd: add function kbd_pending() pckbd: add controller response queue pckbd: add state variable for interrupt source pckbd: PS/2 keyboard throttle pckbd: don't update OBF flags if KBD_STAT_OBF is set pckbd: split out interrupt line changing code ps2: don't deassert irq twice if queue is empty ps2: don't raise an interrupt if queue is full ps2: fix mouse stream corruption hw/input: expand trace info reported for ps2 device Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/input/ps2.c')
-rw-r--r--hw/input/ps2.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 72cdb80ae1..8dd482c1f6 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -212,8 +212,12 @@ 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);
+ ps2_raise_irq(s);
}
void ps2_queue_2(PS2State *s, int b1, int b2)
@@ -224,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)
@@ -236,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)
@@ -249,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. */
@@ -293,7 +297,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 {
@@ -515,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;
}
@@ -645,7 +652,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;