WM8750 qdev coversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
parent
697454eb8e
commit
cdbe40ca83
4
hw/i2c.h
4
hw/i2c.h
|
@ -80,9 +80,7 @@ qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
|
||||||
void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
|
void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
|
||||||
|
|
||||||
/* wm8750.c */
|
/* wm8750.c */
|
||||||
i2c_slave *wm8750_init(i2c_bus *bus);
|
void wm8750_data_req_set(DeviceState *dev,
|
||||||
void wm8750_reset(i2c_slave *i2c);
|
|
||||||
void wm8750_data_req_set(i2c_slave *i2c,
|
|
||||||
void (*data_req)(void *, int, int), void *opaque);
|
void (*data_req)(void *, int, int), void *opaque);
|
||||||
void wm8750_dac_dat(void *opaque, uint32_t sample);
|
void wm8750_dac_dat(void *opaque, uint32_t sample);
|
||||||
uint32_t wm8750_adc_dat(void *opaque);
|
uint32_t wm8750_adc_dat(void *opaque);
|
||||||
|
|
|
@ -235,7 +235,7 @@ typedef struct musicpal_audio_state {
|
||||||
unsigned int play_pos;
|
unsigned int play_pos;
|
||||||
unsigned int last_free;
|
unsigned int last_free;
|
||||||
uint32_t clock_div;
|
uint32_t clock_div;
|
||||||
i2c_slave *wm;
|
DeviceState *wm;
|
||||||
} musicpal_audio_state;
|
} musicpal_audio_state;
|
||||||
|
|
||||||
static void audio_callback(void *opaque, int free_out, int free_in)
|
static void audio_callback(void *opaque, int free_out, int free_in)
|
||||||
|
@ -434,10 +434,7 @@ static i2c_interface *musicpal_audio_init(qemu_irq irq)
|
||||||
i2c->bus = i2c_init_bus();
|
i2c->bus = i2c_init_bus();
|
||||||
i2c->current_addr = -1;
|
i2c->current_addr = -1;
|
||||||
|
|
||||||
s->wm = wm8750_init(i2c->bus);
|
s->wm = i2c_create_slave(i2c->bus, "wm8750", MP_WM_ADDR);
|
||||||
if (!s->wm)
|
|
||||||
return NULL;
|
|
||||||
i2c_set_slave_address(s->wm, MP_WM_ADDR);
|
|
||||||
wm8750_data_req_set(s->wm, audio_callback, s);
|
wm8750_data_req_set(s->wm, audio_callback, s);
|
||||||
|
|
||||||
iomemtype = cpu_register_io_memory(0, musicpal_audio_readfn,
|
iomemtype = cpu_register_io_memory(0, musicpal_audio_readfn,
|
||||||
|
|
|
@ -740,10 +740,10 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
|
||||||
i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
|
i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
|
||||||
|
|
||||||
#ifdef HAS_AUDIO
|
#ifdef HAS_AUDIO
|
||||||
i2c_slave *wm;
|
DeviceState *wm;
|
||||||
|
|
||||||
/* Attach a WM8750 to the bus */
|
/* Attach a WM8750 to the bus */
|
||||||
wm = wm8750_init(bus);
|
wm = i2c_create_slave(bus, "wm8750", 0);
|
||||||
|
|
||||||
spitz_wm8750_addr(wm, 0, 0);
|
spitz_wm8750_addr(wm, 0, 0);
|
||||||
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM,
|
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM,
|
||||||
|
|
30
hw/wm8750.c
30
hw/wm8750.c
|
@ -259,7 +259,7 @@ static void wm8750_clk_update(WM8750State *s, int ext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm8750_reset(i2c_slave *i2c)
|
static void wm8750_reset(i2c_slave *i2c)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *) i2c;
|
WM8750State *s = (WM8750State *) i2c;
|
||||||
s->rate = &wm_rate_table[0];
|
s->rate = &wm_rate_table[0];
|
||||||
|
@ -645,20 +645,14 @@ static int wm8750_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_slave *wm8750_init(i2c_bus *bus)
|
static void wm8750_init(i2c_slave *i2c)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *)
|
WM8750State *s = FROM_I2C_SLAVE(WM8750State, i2c);
|
||||||
i2c_slave_init(bus, 0, sizeof(WM8750State));
|
|
||||||
s->i2c.event = wm8750_event;
|
|
||||||
s->i2c.recv = wm8750_rx;
|
|
||||||
s->i2c.send = wm8750_tx;
|
|
||||||
|
|
||||||
AUD_register_card(CODEC, &s->card);
|
AUD_register_card(CODEC, &s->card);
|
||||||
wm8750_reset(&s->i2c);
|
wm8750_reset(&s->i2c);
|
||||||
|
|
||||||
register_savevm(CODEC, -1, 0, wm8750_save, wm8750_load, s);
|
register_savevm(CODEC, -1, 0, wm8750_save, wm8750_load, s);
|
||||||
|
|
||||||
return &s->i2c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -671,10 +665,10 @@ static void wm8750_fini(i2c_slave *i2c)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void wm8750_data_req_set(i2c_slave *i2c,
|
void wm8750_data_req_set(DeviceState *dev,
|
||||||
void (*data_req)(void *, int, int), void *opaque)
|
void (*data_req)(void *, int, int), void *opaque)
|
||||||
{
|
{
|
||||||
WM8750State *s = (WM8750State *) i2c;
|
WM8750State *s = FROM_I2C_SLAVE(WM8750State, I2C_SLAVE_FROM_QDEV(dev));
|
||||||
s->data_req = data_req;
|
s->data_req = data_req;
|
||||||
s->opaque = opaque;
|
s->opaque = opaque;
|
||||||
}
|
}
|
||||||
|
@ -730,3 +724,17 @@ void wm8750_set_bclk_in(void *opaque, int new_hz)
|
||||||
s->ext_dac_hz = new_hz;
|
s->ext_dac_hz = new_hz;
|
||||||
wm8750_clk_update(s, 1);
|
wm8750_clk_update(s, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static I2CSlaveInfo wm8750_info = {
|
||||||
|
.init = wm8750_init,
|
||||||
|
.event = wm8750_event,
|
||||||
|
.recv = wm8750_rx,
|
||||||
|
.send = wm8750_tx
|
||||||
|
};
|
||||||
|
|
||||||
|
static void wm8750_register_devices(void)
|
||||||
|
{
|
||||||
|
i2c_register_slave("wm8750", sizeof(WM8750State), &wm8750_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
device_init(wm8750_register_devices)
|
||||||
|
|
Loading…
Reference in a new issue