mirror of https://github.com/xemu-project/xemu.git
hw/input/tsc210x: Extract common init code into new function
This deduplicates several lines and will make future changes more concise. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <1d75877cf4cc2a38f87633ff16f9fea3e1bb0c03.1650874791.git.mkletzan@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
e8eed838ec
commit
38e476e88e
|
@ -30,6 +30,7 @@
|
||||||
#include "hw/input/tsc2xxx.h"
|
#include "hw/input/tsc2xxx.h"
|
||||||
#include "hw/irq.h"
|
#include "hw/irq.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
|
||||||
#define TSC_DATA_REGISTERS_PAGE 0x0
|
#define TSC_DATA_REGISTERS_PAGE 0x0
|
||||||
#define TSC_CONTROL_REGISTERS_PAGE 0x1
|
#define TSC_CONTROL_REGISTERS_PAGE 0x1
|
||||||
|
@ -1069,20 +1070,10 @@ static const VMStateDescription vmstate_tsc2301 = {
|
||||||
.fields = vmstatefields_tsc210x,
|
.fields = vmstatefields_tsc210x,
|
||||||
};
|
};
|
||||||
|
|
||||||
uWireSlave *tsc2102_init(qemu_irq pint)
|
static void tsc210x_init(TSC210xState *s,
|
||||||
|
const char *name,
|
||||||
|
const VMStateDescription *vmsd)
|
||||||
{
|
{
|
||||||
TSC210xState *s;
|
|
||||||
|
|
||||||
s = g_new0(TSC210xState, 1);
|
|
||||||
s->x = 160;
|
|
||||||
s->y = 160;
|
|
||||||
s->pressure = 0;
|
|
||||||
s->precision = s->nextprecision = 0;
|
|
||||||
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tsc210x_timer_tick, s);
|
|
||||||
s->pint = pint;
|
|
||||||
s->model = 0x2102;
|
|
||||||
s->name = "tsc2102";
|
|
||||||
|
|
||||||
s->tr[0] = 0;
|
s->tr[0] = 0;
|
||||||
s->tr[1] = 1;
|
s->tr[1] = 1;
|
||||||
s->tr[2] = 1;
|
s->tr[2] = 1;
|
||||||
|
@ -1104,13 +1095,29 @@ uWireSlave *tsc2102_init(qemu_irq pint)
|
||||||
|
|
||||||
tsc210x_reset(s);
|
tsc210x_reset(s);
|
||||||
|
|
||||||
qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
|
qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1, name);
|
||||||
"QEMU TSC2102-driven Touchscreen");
|
|
||||||
|
|
||||||
AUD_register_card(s->name, &s->card);
|
AUD_register_card(s->name, &s->card);
|
||||||
|
|
||||||
qemu_register_reset((void *) tsc210x_reset, s);
|
qemu_register_reset((void *) tsc210x_reset, s);
|
||||||
vmstate_register(NULL, 0, &vmstate_tsc2102, s);
|
vmstate_register(NULL, 0, vmsd, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
uWireSlave *tsc2102_init(qemu_irq pint)
|
||||||
|
{
|
||||||
|
TSC210xState *s;
|
||||||
|
|
||||||
|
s = g_new0(TSC210xState, 1);
|
||||||
|
s->x = 160;
|
||||||
|
s->y = 160;
|
||||||
|
s->pressure = 0;
|
||||||
|
s->precision = s->nextprecision = 0;
|
||||||
|
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tsc210x_timer_tick, s);
|
||||||
|
s->pint = pint;
|
||||||
|
s->model = 0x2102;
|
||||||
|
s->name = "tsc2102";
|
||||||
|
|
||||||
|
tsc210x_init(s, "QEMU TSC2102-driven Touchscreen", &vmstate_tsc2102);
|
||||||
|
|
||||||
return &s->chip;
|
return &s->chip;
|
||||||
}
|
}
|
||||||
|
@ -1131,34 +1138,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
|
||||||
s->model = 0x2301;
|
s->model = 0x2301;
|
||||||
s->name = "tsc2301";
|
s->name = "tsc2301";
|
||||||
|
|
||||||
s->tr[0] = 0;
|
tsc210x_init(s, "QEMU TSC2301-driven Touchscreen", &vmstate_tsc2301);
|
||||||
s->tr[1] = 1;
|
|
||||||
s->tr[2] = 1;
|
|
||||||
s->tr[3] = 0;
|
|
||||||
s->tr[4] = 1;
|
|
||||||
s->tr[5] = 0;
|
|
||||||
s->tr[6] = 1;
|
|
||||||
s->tr[7] = 0;
|
|
||||||
|
|
||||||
s->chip.opaque = s;
|
|
||||||
s->chip.send = (void *) tsc210x_write;
|
|
||||||
s->chip.receive = (void *) tsc210x_read;
|
|
||||||
|
|
||||||
s->codec.opaque = s;
|
|
||||||
s->codec.tx_swallow = (void *) tsc210x_i2s_swallow;
|
|
||||||
s->codec.set_rate = (void *) tsc210x_i2s_set_rate;
|
|
||||||
s->codec.in.fifo = s->in_fifo;
|
|
||||||
s->codec.out.fifo = s->out_fifo;
|
|
||||||
|
|
||||||
tsc210x_reset(s);
|
|
||||||
|
|
||||||
qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
|
|
||||||
"QEMU TSC2301-driven Touchscreen");
|
|
||||||
|
|
||||||
AUD_register_card(s->name, &s->card);
|
|
||||||
|
|
||||||
qemu_register_reset((void *) tsc210x_reset, s);
|
|
||||||
vmstate_register(NULL, 0, &vmstate_tsc2301, s);
|
|
||||||
|
|
||||||
return &s->chip;
|
return &s->chip;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue