[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/33] hw/input/stellaris_gamepad: Remove StellarisGamepadButton s
|
From: |
Peter Maydell |
|
Subject: |
[PULL 05/33] hw/input/stellaris_gamepad: Remove StellarisGamepadButton struct |
|
Date: |
Thu, 2 Nov 2023 17:38:07 +0000 |
Currently for each button on the device we have a
StellarisGamepadButton struct which has the irq, keycode and pressed
state for it. When we convert to qdev, the qdev property and GPIO
APIs are going to require that we have separate arrays for the irqs
and keycodes. Convert from array-of-structs to three separate arrays
in preparation.
This is a migration compatibility break for the stellaris boards
(lm3s6965evb, lm3s811evb).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231030114802.3671871-5-peter.maydell@linaro.org
--
v1=>v2: mention migration compat break in commit message;
bump version fields in vmstate
---
hw/input/stellaris_gamepad.c | 47 ++++++++++++------------------------
1 file changed, 16 insertions(+), 31 deletions(-)
diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c
index 377101a4035..82ddc47a26d 100644
--- a/hw/input/stellaris_gamepad.c
+++ b/hw/input/stellaris_gamepad.c
@@ -14,15 +14,11 @@
#include "ui/console.h"
typedef struct {
- qemu_irq irq;
- int keycode;
- uint8_t pressed;
-} StellarisGamepadButton;
-
-typedef struct {
- StellarisGamepadButton *buttons;
- int num_buttons;
+ uint32_t num_buttons;
int extension;
+ qemu_irq *irqs;
+ uint32_t *keycodes;
+ uint8_t *pressed;
} StellarisGamepad;
static void stellaris_gamepad_put_key(void * opaque, int keycode)
@@ -40,36 +36,23 @@ static void stellaris_gamepad_put_key(void * opaque, int
keycode)
keycode = (keycode & 0x7f) | s->extension;
for (i = 0; i < s->num_buttons; i++) {
- if (s->buttons[i].keycode == keycode
- && s->buttons[i].pressed != down) {
- s->buttons[i].pressed = down;
- qemu_set_irq(s->buttons[i].irq, down);
+ if (s->keycodes[i] == keycode && s->pressed[i] != down) {
+ s->pressed[i] = down;
+ qemu_set_irq(s->irqs[i], down);
}
}
s->extension = 0;
}
-static const VMStateDescription vmstate_stellaris_button = {
- .name = "stellaris_button",
- .version_id = 0,
- .minimum_version_id = 0,
- .fields = (VMStateField[]) {
- VMSTATE_UINT8(pressed, StellarisGamepadButton),
- VMSTATE_END_OF_LIST()
- }
-};
-
static const VMStateDescription vmstate_stellaris_gamepad = {
.name = "stellaris_gamepad",
- .version_id = 2,
- .minimum_version_id = 2,
+ .version_id = 3,
+ .minimum_version_id = 3,
.fields = (VMStateField[]) {
VMSTATE_INT32(extension, StellarisGamepad),
- VMSTATE_STRUCT_VARRAY_POINTER_INT32(buttons, StellarisGamepad,
- num_buttons,
- vmstate_stellaris_button,
- StellarisGamepadButton),
+ VMSTATE_VARRAY_UINT32(pressed, StellarisGamepad, num_buttons,
+ 0, vmstate_info_uint8, uint8_t),
VMSTATE_END_OF_LIST()
}
};
@@ -81,10 +64,12 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int
*keycode)
int i;
s = g_new0(StellarisGamepad, 1);
- s->buttons = g_new0(StellarisGamepadButton, n);
+ s->irqs = g_new0(qemu_irq, n);
+ s->keycodes = g_new0(uint32_t, n);
+ s->pressed = g_new0(uint8_t, n);
for (i = 0; i < n; i++) {
- s->buttons[i].irq = irq[i];
- s->buttons[i].keycode = keycode[i];
+ s->irqs[i] = irq[i];
+ s->keycodes[i] = keycode[i];
}
s->num_buttons = n;
qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);
--
2.34.1
- [PULL 00/33] target-arm queue, Peter Maydell, 2023/11/02
- [PULL 01/33] linux-user/elfload: Add missing arm64 hwcap values, Peter Maydell, 2023/11/02
- [PULL 07/33] hw/input/stellaris_gamepad: Convert to qemu_input_handler_register(), Peter Maydell, 2023/11/02
- [PULL 03/33] hw/input/stellaris_gamepad: Rename structs to our usual convention, Peter Maydell, 2023/11/02
- [PULL 06/33] hw/input/stellaris_input: Convert to qdev, Peter Maydell, 2023/11/02
- [PULL 05/33] hw/input/stellaris_gamepad: Remove StellarisGamepadButton struct,
Peter Maydell <=
- [PULL 09/33] docs/specs/edu: Convert to rST, Peter Maydell, 2023/11/02
- [PULL 15/33] docs/specs/vmgenid: Convert to rST, Peter Maydell, 2023/11/02
- [PULL 11/33] docs/specs/pvpanic: Convert to rST, Peter Maydell, 2023/11/02
- [PULL 17/33] hw/arm/pxa2xx_gpio: Pass CPU using QOM link property, Peter Maydell, 2023/11/02
- [PULL 18/33] hw/watchdog/wdt_imx2: Trace MMIO access, Peter Maydell, 2023/11/02
- [PULL 08/33] docs/specs/vmw_pvscsi-spec: Convert to rST, Peter Maydell, 2023/11/02
- [PULL 10/33] docs/specs/ivshmem-spec: Convert to rST, Peter Maydell, 2023/11/02
- [PULL 14/33] docs/specs/vmcoreinfo: Convert to rST, Peter Maydell, 2023/11/02
- [PULL 19/33] hw/watchdog/wdt_imx2: Trace timer activity, Peter Maydell, 2023/11/02
- [PULL 24/33] linux-user: Report AArch64 hwcap2 fields above bit 31, Peter Maydell, 2023/11/02