提交 22d83b14 编写于 作者: P Paul Brook

Push AUD_init down to devices

Now we can safely call AUD_init multiple times we can push it down to
individual audio devices, rather than having to pass it from the board
init.
Signed-off-by: NPaul Brook <paul@codesourcery.com>
上级 0d9acba8
......@@ -1308,8 +1308,9 @@ static void ac97_on_reset (void *opaque)
mixer_reset (s);
}
int ac97_init (PCIBus *bus, AudioState *audio)
int ac97_init (PCIBus *bus)
{
AudioState *audio = AUD_init();
PCIAC97LinkState *d;
AC97LinkState *s;
uint8_t *c;
......@@ -1319,11 +1320,6 @@ int ac97_init (PCIBus *bus, AudioState *audio)
return -1;
}
if (!audio) {
AUD_log ("ac97", "No audio state\n");
return -1;
}
d = (PCIAC97LinkState *) pci_register_device (bus, "AC97",
sizeof (PCIAC97LinkState),
-1, NULL, NULL);
......
......@@ -277,16 +277,12 @@ static void Adlib_fini (AdlibState *s)
AUD_remove_card (&s->card);
}
int Adlib_init (AudioState *audio, qemu_irq *pic)
int Adlib_init (qemu_irq *pic)
{
AudioState *audio = AUD_init();
AdlibState *s = &glob_adlib;
struct audsettings as;
if (!audio) {
dolog ("No audio state\n");
return -1;
}
#ifdef HAS_YMF262
if (YMF262Init (1, 14318180, conf.freq)) {
dolog ("YMF262Init %d failed\n", conf.freq);
......
/* es1370.c */
int es1370_init (PCIBus *bus, AudioState *s);
int es1370_init(PCIBus *bus);
/* sb16.c */
int SB16_init (AudioState *s, qemu_irq *pic);
int SB16_init(qemu_irq *pic);
/* adlib.c */
int Adlib_init (AudioState *s, qemu_irq *pic);
int Adlib_init(qemu_irq *pic);
/* gus.c */
int GUS_init (AudioState *s, qemu_irq *pic);
int GUS_init(qemu_irq *pic);
/* ac97.c */
int ac97_init (PCIBus *buf, AudioState *s);
int ac97_init(PCIBus *buf);
/* cs4231a.c */
int cs4231a_init (AudioState *s, qemu_irq *pic);
int cs4231a_init(qemu_irq *pic);
......@@ -636,16 +636,12 @@ static int cs_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
int cs4231a_init (AudioState *audio, qemu_irq *pic)
int cs4231a_init (qemu_irq *pic)
{
AudioState *audio = AUD_init();
int i;
CSState *s;
if (!audio) {
lerr ("No audio state\n");
return -1;
}
s = qemu_mallocz (sizeof (*s));
s->pic = pic;
......
......@@ -17,9 +17,8 @@ void ads7846_write(void *opaque, uint32_t value);
ADS7846State *ads7846_init(qemu_irq penirq);
/* tsc210x.c */
uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio);
uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
qemu_irq dav, AudioState *audio);
uWireSlave *tsc2102_init(qemu_irq pint);
uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
I2SCodec *tsc210x_codec(uWireSlave *chip);
uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
void tsc210x_set_transform(uWireSlave *chip,
......
......@@ -1005,8 +1005,9 @@ static void es1370_on_reset (void *opaque)
es1370_reset (s);
}
int es1370_init (PCIBus *bus, AudioState *audio)
int es1370_init (PCIBus *bus)
{
AudioState *audio = AUD_init();
PCIES1370State *d;
ES1370State *s;
uint8_t *c;
......@@ -1016,11 +1017,6 @@ int es1370_init (PCIBus *bus, AudioState *audio)
return -1;
}
if (!audio) {
dolog ("No audio state\n");
return -1;
}
d = (PCIES1370State *) pci_register_device (bus, "ES1370",
sizeof (PCIES1370State),
-1, NULL, NULL);
......
......@@ -250,16 +250,12 @@ static int GUS_load (QEMUFile *f, void *opaque, int version_id)
return 0;
}
int GUS_init (AudioState *audio, qemu_irq *pic)
int GUS_init (qemu_irq *pic)
{
AudioState *audio = AUD_init();
GUSState *s;
struct audsettings as;
if (!audio) {
dolog ("No audio state\n");
return -1;
}
s = qemu_mallocz (sizeof (*s));
AUD_register_card (audio, "gus", &s->card);
......
......@@ -60,7 +60,7 @@ qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
/* wm8750.c */
i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
i2c_slave *wm8750_init(i2c_bus *bus);
void wm8750_reset(i2c_slave *i2c);
void wm8750_data_req_set(i2c_slave *i2c,
void (*data_req)(void *, int, int), void *opaque);
......
......@@ -104,13 +104,10 @@ static void audio_init(qemu_irq *pic)
}
if (audio_enabled) {
AudioState *s;
s = AUD_init();
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
if (c->isa) {
c->init.init_isa(s, pic);
c->init.init_isa(pic);
}
}
}
......
......@@ -469,12 +469,9 @@ static void audio_init (PCIBus *pci_bus)
}
if (audio_enabled) {
AudioState *s;
s = AUD_init ();
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
c->init.init_pci (pci_bus, s);
c->init.init_pci(pci_bus);
}
}
}
......
......@@ -422,13 +422,10 @@ static CPUWriteMemoryFunc *musicpal_audio_writefn[] = {
static i2c_interface *musicpal_audio_init(qemu_irq irq)
{
AudioState *audio;
musicpal_audio_state *s;
i2c_interface *i2c;
int iomemtype;
audio = AUD_init();
s = qemu_mallocz(sizeof(musicpal_audio_state));
s->irq = irq;
......@@ -436,7 +433,7 @@ static i2c_interface *musicpal_audio_init(qemu_irq irq)
i2c->bus = i2c_init_bus();
i2c->current_addr = -1;
s->wm = wm8750_init(i2c->bus, audio);
s->wm = wm8750_init(i2c->bus);
if (!s->wm)
return NULL;
i2c_set_slave_address(s->wm, MP_WM_ADDR);
......
......@@ -252,7 +252,7 @@ static void n800_tsc_kbd_setup(struct n800_s *s)
qemu_irq kbirq = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_KP_IRQ_GPIO)[0];
qemu_irq dav = omap2_gpio_in_get(s->cpu->gpif, N800_TSC_TS_GPIO)[0];
s->ts.chip = tsc2301_init(penirq, kbirq, dav, 0);
s->ts.chip = tsc2301_init(penirq, kbirq, dav);
s->ts.opaque = s->ts.chip->opaque;
s->ts.txrx = tsc210x_txrx;
......
......@@ -1973,7 +1973,6 @@ struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta,
omap_eac_reset(s);
#ifdef HAS_AUDIO
/* TODO: do AUD_init globally for machine */
AUD_register_card(AUD_init(), "OMAP EAC", &s->codec.card);
iomemtype = cpu_register_io_memory(0, omap_eac_readfn,
......
......@@ -93,14 +93,8 @@ static MouseTransformInfo palmte_pointercal = {
static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
{
uWireSlave *tsc;
AudioState *audio = 0;
#ifdef HAS_AUDIO
audio = AUD_init();
#endif
tsc = tsc2102_init(omap_gpio_in_get(cpu->gpio)[PALMTE_PINTDAV_GPIO],
audio);
tsc = tsc2102_init(omap_gpio_in_get(cpu->gpio)[PALMTE_PINTDAV_GPIO]);
omap_uwire_attach(cpu->microwire, tsc, 0);
omap_mcbsp_i2s_attach(cpu->mcbsp1, tsc210x_codec(tsc));
......
......@@ -788,17 +788,13 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
}
if (audio_enabled) {
AudioState *s;
s = AUD_init ();
for (c = soundhw; c->name; ++c) {
if (c->enabled) {
if (c->isa) {
c->init.init_isa (s, pic);
}
else {
c->init.init_isa(pic);
} else {
if (pci_bus) {
c->init.init_pci (pci_bus, s);
c->init.init_pci(pci_bus);
}
}
}
......
......@@ -119,7 +119,7 @@ extern int no_hpet;
/* pcspk.c */
void pcspk_init(PITState *);
int pcspk_audio_init(AudioState *, qemu_irq *pic);
int pcspk_audio_init(qemu_irq *pic);
/* piix_pci.c */
PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic);
......
......@@ -96,15 +96,12 @@ static void pcspk_callback(void *opaque, int free)
}
}
int pcspk_audio_init(AudioState *audio, qemu_irq *pic)
int pcspk_audio_init(qemu_irq *pic)
{
AudioState *audio = AUD_init();
PCSpkState *s = &pcspk_state;
struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
if (!audio) {
AUD_log(s_spk, "No audio state\n");
return -1;
}
AUD_register_card(audio, s_spk, &s->card);
s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
......
......@@ -696,7 +696,6 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
}
i8042_init(i8259[1], i8259[12], 0x60);
DMA_init(1);
// AUD_init();
// SB16_init();
for(i = 0; i < MAX_FD; i++) {
......
......@@ -1398,18 +1398,14 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id)
return 0;
}
int SB16_init (AudioState *audio, qemu_irq *pic)
int SB16_init (qemu_irq *pic)
{
AudioState *audio = AUD_init();
SB16State *s;
int i;
static const uint8_t dsp_write_ports[] = {0x6, 0xc};
static const uint8_t dsp_read_ports[] = {0x6, 0xa, 0xc, 0xd, 0xe, 0xf};
if (!audio) {
dolog ("No audio state\n");
return -1;
}
s = qemu_mallocz (sizeof (*s));
s->cmd = -1;
......
......@@ -740,12 +740,10 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
#ifdef HAS_AUDIO
AudioState *audio;
i2c_slave *wm;
audio = AUD_init();
/* Attach a WM8750 to the bus */
wm = wm8750_init(bus, audio);
wm = wm8750_init(bus);
spitz_wm8750_addr(wm, 0, 0);
pxa2xx_gpio_out_set(cpu->gpio, SPITZ_GPIO_WM,
......
......@@ -684,7 +684,6 @@ static void tsc2102_audio_register_write(
"wrong value written into Audio 1\n");
#endif
tsc2102_audio_rate_update(s);
if (s->audio)
tsc2102_audio_output_update(s);
return;
......@@ -729,7 +728,6 @@ static void tsc2102_audio_register_write(
"wrong value written into Power\n");
#endif
tsc2102_audio_rate_update(s);
if (s->audio)
tsc2102_audio_output_update(s);
return;
......@@ -741,7 +739,6 @@ static void tsc2102_audio_register_write(
fprintf(stderr, "tsc2102_audio_register_write: "
"wrong value written into Audio 3\n");
#endif
if (s->audio)
tsc2102_audio_output_update(s);
return;
......@@ -1105,7 +1102,7 @@ static int tsc210x_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
uWireSlave *tsc2102_init(qemu_irq pint)
{
TSC210xState *s;
......@@ -1120,7 +1117,7 @@ uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
s->pint = pint;
s->model = 0x2102;
s->name = "tsc2102";
s->audio = audio;
s->audio = AUD_init();;
s->tr[0] = 0;
s->tr[1] = 1;
......@@ -1146,7 +1143,6 @@ uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
"QEMU TSC2102-driven Touchscreen");
if (s->audio)
AUD_register_card(s->audio, s->name, &s->card);
qemu_register_reset((void *) tsc210x_reset, s);
......@@ -1156,8 +1152,7 @@ uWireSlave *tsc2102_init(qemu_irq pint, AudioState *audio)
return &s->chip;
}
uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
qemu_irq dav, AudioState *audio)
uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
{
TSC210xState *s;
......@@ -1174,7 +1169,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
s->davint = dav;
s->model = 0x2301;
s->name = "tsc2301";
s->audio = audio;
s->audio = AUD_init();
s->tr[0] = 0;
s->tr[1] = 1;
......@@ -1200,7 +1195,6 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq,
qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1,
"QEMU TSC2301-driven Touchscreen");
if (s->audio)
AUD_register_card(s->audio, s->name, &s->card);
qemu_register_reset((void *) tsc210x_reset, s);
......
......@@ -645,8 +645,9 @@ static int wm8750_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio)
i2c_slave *wm8750_init(i2c_bus *bus)
{
AudioState *audio = AUD_init();
WM8750State *s = (WM8750State *)
i2c_slave_init(bus, 0, sizeof(WM8750State));
s->i2c.event = wm8750_event;
......
......@@ -241,8 +241,8 @@ struct soundhw {
int enabled;
int isa;
union {
int (*init_isa) (AudioState *s, qemu_irq *pic);
int (*init_pci) (PCIBus *bus, AudioState *s);
int (*init_isa) (qemu_irq *pic);
int (*init_pci) (PCIBus *bus);
} init;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册