mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
hw/input/stellaris_input: Convert to qdev
Convert the hw/input/stellaris_input device to qdev. The interface uses an array property for the board to specify the keycodes to use, so the s->keycodes memory is now allocated by the array-property machinery. 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-6-peter.maydell@linaro.org
This commit is contained in:
parent
5f8d505e3a
commit
a75f336b97
3 changed files with 87 additions and 32 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "hw/timer/stellaris-gptm.h"
|
||||
#include "hw/qdev-clock.h"
|
||||
#include "qom/object.h"
|
||||
#include "qapi/qmp/qlist.h"
|
||||
|
||||
#define GPIO_A 0
|
||||
#define GPIO_B 1
|
||||
|
@ -1274,16 +1275,27 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
|
|||
sysbus_connect_irq(SYS_BUS_DEVICE(enet), 0, qdev_get_gpio_in(nvic, 42));
|
||||
}
|
||||
if (board->peripherals & BP_GAMEPAD) {
|
||||
qemu_irq gpad_irq[5];
|
||||
QList *gpad_keycode_list = qlist_new();
|
||||
static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };
|
||||
DeviceState *gpad;
|
||||
|
||||
gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); /* up */
|
||||
gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); /* down */
|
||||
gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); /* left */
|
||||
gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); /* right */
|
||||
gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); /* select */
|
||||
gpad = qdev_new(TYPE_STELLARIS_GAMEPAD);
|
||||
for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) {
|
||||
qlist_append_int(gpad_keycode_list, gpad_keycode[i]);
|
||||
}
|
||||
qdev_prop_set_array(gpad, "keycodes", gpad_keycode_list);
|
||||
sysbus_realize_and_unref(SYS_BUS_DEVICE(gpad), &error_fatal);
|
||||
|
||||
stellaris_gamepad_init(5, gpad_irq, gpad_keycode);
|
||||
qdev_connect_gpio_out(gpad, 0,
|
||||
qemu_irq_invert(gpio_in[GPIO_E][0])); /* up */
|
||||
qdev_connect_gpio_out(gpad, 1,
|
||||
qemu_irq_invert(gpio_in[GPIO_E][1])); /* down */
|
||||
qdev_connect_gpio_out(gpad, 2,
|
||||
qemu_irq_invert(gpio_in[GPIO_E][2])); /* left */
|
||||
qdev_connect_gpio_out(gpad, 3,
|
||||
qemu_irq_invert(gpio_in[GPIO_E][3])); /* right */
|
||||
qdev_connect_gpio_out(gpad, 4,
|
||||
qemu_irq_invert(gpio_in[GPIO_F][1])); /* select */
|
||||
}
|
||||
for (i = 0; i < 7; i++) {
|
||||
if (board->dc4 & (1 << i)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue