/* #define VERBOSE_ES1370 */
#define SILENT_ES1370
-#include "vl.h"
+#include "hw.h"
+#include "audiodev.h"
+#include "audio/audio.h"
+#include "pci.h"
/* Missing stuff:
SCTRL_P[12](END|ST)INC
#endif
#ifndef SILENT_ES1370
-#define lwarn(...) AUD_log ("es1370: warning:", __VA_ARGS__)
+#define lwarn(...) AUD_log ("es1370: warning", __VA_ARGS__)
#else
#define lwarn(...)
#endif
typedef struct ES1370State {
PCIDevice *pci_dev;
+ QEMUSoundCard card;
struct chan chan[NB_CHANNELS];
SWVoiceOut *dac_voice[2];
SWVoiceIn *adc_voice;
else {
s->status = new_status & ~STAT_INTR;
}
- pci_set_irq (s->pci_dev, 0, !!level);
+ qemu_set_irq(s->pci_dev->irq[0], !!level);
}
static void es1370_reset (ES1370State *s)
d->scount = 0;
d->leftover = 0;
if (i == ADC_CHANNEL) {
- AUD_close_in (s->adc_voice);
+ AUD_close_in (&s->card, s->adc_voice);
s->adc_voice = NULL;
}
else {
- AUD_close_out (s->dac_voice[i]);
+ AUD_close_out (&s->card, s->dac_voice[i]);
s->dac_voice[i] = NULL;
}
}
- pci_set_irq (s->pci_dev, 0, 0);
+ qemu_irq_lower(s->pci_dev->irq[0]);
}
static void es1370_maybe_lower_irq (ES1370State *s, uint32_t sctl)
(new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8,
d->shift);
if (new_freq) {
+ audsettings_t as;
+
+ as.freq = new_freq;
+ as.nchannels = 1 << (new_fmt & 1);
+ as.fmt = (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8;
+ as.endianness = 0;
+
if (i == ADC_CHANNEL) {
s->adc_voice =
AUD_open_in (
+ &s->card,
s->adc_voice,
"es1370.adc",
s,
es1370_adc_callback,
- new_freq,
- 1 << (new_fmt & 1),
- (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8
+ &as
);
}
else {
s->dac_voice[i] =
AUD_open_out (
+ &s->card,
s->dac_voice[i],
i ? "es1370.dac2" : "es1370.dac1",
s,
i ? es1370_dac2_callback : es1370_dac1_callback,
- new_freq,
- 1 << (new_fmt & 1),
- (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8
+ &as
);
}
}
IO_WRITE_PROTO (es1370_writeb)
{
ES1370State *s = opaque;
- addr = es1370_fixup (s, addr);
uint32_t shift, mask;
+ addr = es1370_fixup (s, addr);
+
switch (addr) {
case ES1370_REG_CONTROL:
case ES1370_REG_CONTROL + 1:
ldebug ("chan %d frame address %#x\n", d - &s->chan[0], val);
break;
+ case ES1370_REG_PHANTOM_FRAMECNT:
+ lwarn ("writing to phantom frame count %#x\n", val);
+ break;
+ case ES1370_REG_PHANTOM_FRAMEADR:
+ lwarn ("writing to phantom frame address %#x\n", val);
+ break;
+
case ES1370_REG_ADC_FRAMECNT:
d++;
case ES1370_REG_DAC2_FRAMECNT:
val = d->scount >> 16;
break;
+ case ES1370_REG_ADC_FRAMECNT:
+ d++;
+ case ES1370_REG_DAC2_FRAMECNT:
+ d++;
+ case ES1370_REG_DAC1_FRAMECNT:
+ val = d->frame_cnt & 0xffff;
+ break;
+
+ case ES1370_REG_ADC_FRAMECNT + 2:
+ d++;
+ case ES1370_REG_DAC2_FRAMECNT + 2:
+ d++;
+ case ES1370_REG_DAC1_FRAMECNT + 2:
+ val = d->frame_cnt >> 16;
+ break;
+
default:
val = ~0;
lwarn ("readw %#x -> %#x\n", addr, val);
val = d->frame_addr;
break;
+ case ES1370_REG_PHANTOM_FRAMECNT:
+ val = ~0U;
+ lwarn ("reading from phantom frame count\n");
+ break;
+ case ES1370_REG_PHANTOM_FRAMEADR:
+ val = ~0U;
+ lwarn ("reading from phantom frame address\n");
+ break;
+
default:
val = ~0U;
lwarn ("readl %#x -> %#x\n", addr, val);
while (temp) {
int acquired, to_copy;
- to_copy = audio_MIN (temp, sizeof (tmpbuf));
+ to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf));
acquired = AUD_read (s->adc_voice, tmpbuf, to_copy);
if (!acquired)
break;
while (temp) {
int copied, to_copy;
- to_copy = audio_MIN (temp, sizeof (tmpbuf));
+ to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf));
cpu_physical_memory_read (addr, tmpbuf, to_copy);
copied = AUD_write (voice, tmpbuf, to_copy);
if (!copied)
if (s->sctl & loop_sel) {
/* Bah, how stupid is that having a 0 represent true value?
i just spent few hours on this shit */
- lwarn ("whoops non looping mode\n");
+ AUD_log ("es1370: warning", "non looping mode\n");
}
else {
d->frame_cnt = size;
- if (cnt <= d->frame_cnt)
+ if ((uint32_t) cnt <= d->frame_cnt)
d->frame_cnt |= cnt << 16;
}
PCIES1370State *d = (PCIES1370State *) pci_dev;
ES1370State *s = &d->es1370;
+ (void) region_num;
+ (void) size;
+ (void) type;
+
register_ioport_write (addr, 0x40 * 4, 1, es1370_writeb, s);
register_ioport_write (addr, 0x40 * 2, 2, es1370_writew, s);
register_ioport_write (addr, 0x40, 4, es1370_writel, s);
qemu_get_be32s (f, &d->frame_cnt);
if (i == ADC_CHANNEL) {
if (s->adc_voice) {
- AUD_close_in (s->adc_voice);
+ AUD_close_in (&s->card, s->adc_voice);
s->adc_voice = NULL;
}
}
else {
if (s->dac_voice[i]) {
- AUD_close_out (s->dac_voice[i]);
+ AUD_close_out (&s->card, s->dac_voice[i]);
s->dac_voice[i] = NULL;
}
}
es1370_reset (s);
}
-int es1370_init (PCIBus *bus)
+int es1370_init (PCIBus *bus, AudioState *audio)
{
PCIES1370State *d;
ES1370State *s;
uint8_t *c;
+ if (!bus) {
+ dolog ("No PCI bus\n");
+ return -1;
+ }
+
+ if (!audio) {
+ dolog ("No audio state\n");
+ return -1;
+ }
+
d = (PCIES1370State *) pci_register_device (bus, "ES1370",
sizeof (PCIES1370State),
-1, NULL, NULL);
if (!d) {
- fprintf (stderr, "Failed to register PCI device for ES1370\n");
+ AUD_log (NULL, "Failed to register PCI device for ES1370\n");
return -1;
}
pci_register_io_region (&d->dev, 0, 256, PCI_ADDRESS_SPACE_IO, es1370_map);
register_savevm ("es1370", 0, 1, es1370_save, es1370_load, s);
qemu_register_reset (es1370_on_reset, s);
+
+ AUD_register_card (audio, "es1370", &s->card);
es1370_reset (s);
return 0;
}