| 265 |
typedef struct ES1370State { |
typedef struct ES1370State { |
| 266 |
PCIDevice *pci_dev; |
PCIDevice *pci_dev; |
| 267 |
|
|
| 268 |
|
QEMUSoundCard card; |
| 269 |
struct chan chan[NB_CHANNELS]; |
struct chan chan[NB_CHANNELS]; |
| 270 |
SWVoiceOut *dac_voice[2]; |
SWVoiceOut *dac_voice[2]; |
| 271 |
SWVoiceIn *adc_voice; |
SWVoiceIn *adc_voice; |
| 342 |
d->scount = 0; |
d->scount = 0; |
| 343 |
d->leftover = 0; |
d->leftover = 0; |
| 344 |
if (i == ADC_CHANNEL) { |
if (i == ADC_CHANNEL) { |
| 345 |
AUD_close_in (s->adc_voice); |
AUD_close_in (&s->card, s->adc_voice); |
| 346 |
s->adc_voice = NULL; |
s->adc_voice = NULL; |
| 347 |
} |
} |
| 348 |
else { |
else { |
| 349 |
AUD_close_out (s->dac_voice[i]); |
AUD_close_out (&s->card, s->dac_voice[i]); |
| 350 |
s->dac_voice[i] = NULL; |
s->dac_voice[i] = NULL; |
| 351 |
} |
} |
| 352 |
} |
} |
| 418 |
(new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8, |
(new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8, |
| 419 |
d->shift); |
d->shift); |
| 420 |
if (new_freq) { |
if (new_freq) { |
| 421 |
|
audsettings_t as; |
| 422 |
|
|
| 423 |
|
as.freq = new_freq; |
| 424 |
|
as.nchannels = 1 << (new_fmt & 1); |
| 425 |
|
as.fmt = (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8; |
| 426 |
|
|
| 427 |
if (i == ADC_CHANNEL) { |
if (i == ADC_CHANNEL) { |
| 428 |
s->adc_voice = |
s->adc_voice = |
| 429 |
AUD_open_in ( |
AUD_open_in ( |
| 430 |
|
&s->card, |
| 431 |
s->adc_voice, |
s->adc_voice, |
| 432 |
"es1370.adc", |
"es1370.adc", |
| 433 |
s, |
s, |
| 434 |
es1370_adc_callback, |
es1370_adc_callback, |
| 435 |
new_freq, |
&as |
|
1 << (new_fmt & 1), |
|
|
(new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8 |
|
| 436 |
); |
); |
| 437 |
} |
} |
| 438 |
else { |
else { |
| 439 |
s->dac_voice[i] = |
s->dac_voice[i] = |
| 440 |
AUD_open_out ( |
AUD_open_out ( |
| 441 |
|
&s->card, |
| 442 |
s->dac_voice[i], |
s->dac_voice[i], |
| 443 |
i ? "es1370.dac2" : "es1370.dac1", |
i ? "es1370.dac2" : "es1370.dac1", |
| 444 |
s, |
s, |
| 445 |
i ? es1370_dac2_callback : es1370_dac1_callback, |
i ? es1370_dac2_callback : es1370_dac1_callback, |
| 446 |
new_freq, |
&as |
|
1 << (new_fmt & 1), |
|
|
(new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8 |
|
| 447 |
); |
); |
| 448 |
} |
} |
| 449 |
} |
} |
| 766 |
while (temp) { |
while (temp) { |
| 767 |
int acquired, to_copy; |
int acquired, to_copy; |
| 768 |
|
|
| 769 |
to_copy = audio_MIN (temp, sizeof (tmpbuf)); |
to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf)); |
| 770 |
acquired = AUD_read (s->adc_voice, tmpbuf, to_copy); |
acquired = AUD_read (s->adc_voice, tmpbuf, to_copy); |
| 771 |
if (!acquired) |
if (!acquired) |
| 772 |
break; |
break; |
| 784 |
while (temp) { |
while (temp) { |
| 785 |
int copied, to_copy; |
int copied, to_copy; |
| 786 |
|
|
| 787 |
to_copy = audio_MIN (temp, sizeof (tmpbuf)); |
to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf)); |
| 788 |
cpu_physical_memory_read (addr, tmpbuf, to_copy); |
cpu_physical_memory_read (addr, tmpbuf, to_copy); |
| 789 |
copied = AUD_write (voice, tmpbuf, to_copy); |
copied = AUD_write (voice, tmpbuf, to_copy); |
| 790 |
if (!copied) |
if (!copied) |
| 817 |
else { |
else { |
| 818 |
d->frame_cnt = size; |
d->frame_cnt = size; |
| 819 |
|
|
| 820 |
if (cnt <= d->frame_cnt) |
if ((uint32_t) cnt <= d->frame_cnt) |
| 821 |
d->frame_cnt |= cnt << 16; |
d->frame_cnt |= cnt << 16; |
| 822 |
} |
} |
| 823 |
|
|
| 881 |
PCIES1370State *d = (PCIES1370State *) pci_dev; |
PCIES1370State *d = (PCIES1370State *) pci_dev; |
| 882 |
ES1370State *s = &d->es1370; |
ES1370State *s = &d->es1370; |
| 883 |
|
|
| 884 |
|
(void) region_num; |
| 885 |
|
(void) size; |
| 886 |
|
(void) type; |
| 887 |
|
|
| 888 |
register_ioport_write (addr, 0x40 * 4, 1, es1370_writeb, s); |
register_ioport_write (addr, 0x40 * 4, 1, es1370_writeb, s); |
| 889 |
register_ioport_write (addr, 0x40 * 2, 2, es1370_writew, s); |
register_ioport_write (addr, 0x40 * 2, 2, es1370_writew, s); |
| 890 |
register_ioport_write (addr, 0x40, 4, es1370_writel, s); |
register_ioport_write (addr, 0x40, 4, es1370_writel, s); |
| 932 |
qemu_get_be32s (f, &d->frame_cnt); |
qemu_get_be32s (f, &d->frame_cnt); |
| 933 |
if (i == ADC_CHANNEL) { |
if (i == ADC_CHANNEL) { |
| 934 |
if (s->adc_voice) { |
if (s->adc_voice) { |
| 935 |
AUD_close_in (s->adc_voice); |
AUD_close_in (&s->card, s->adc_voice); |
| 936 |
s->adc_voice = NULL; |
s->adc_voice = NULL; |
| 937 |
} |
} |
| 938 |
} |
} |
| 939 |
else { |
else { |
| 940 |
if (s->dac_voice[i]) { |
if (s->dac_voice[i]) { |
| 941 |
AUD_close_out (s->dac_voice[i]); |
AUD_close_out (&s->card, s->dac_voice[i]); |
| 942 |
s->dac_voice[i] = NULL; |
s->dac_voice[i] = NULL; |
| 943 |
} |
} |
| 944 |
} |
} |
| 962 |
es1370_reset (s); |
es1370_reset (s); |
| 963 |
} |
} |
| 964 |
|
|
| 965 |
int es1370_init (PCIBus *bus) |
int es1370_init (PCIBus *bus, AudioState *audio) |
| 966 |
{ |
{ |
| 967 |
PCIES1370State *d; |
PCIES1370State *d; |
| 968 |
ES1370State *s; |
ES1370State *s; |
| 969 |
uint8_t *c; |
uint8_t *c; |
| 970 |
|
|
| 971 |
|
if (!bus) { |
| 972 |
|
dolog ("No PCI bus\n"); |
| 973 |
|
return -1; |
| 974 |
|
} |
| 975 |
|
|
| 976 |
|
if (!audio) { |
| 977 |
|
dolog ("No audio state\n"); |
| 978 |
|
return -1; |
| 979 |
|
} |
| 980 |
|
|
| 981 |
d = (PCIES1370State *) pci_register_device (bus, "ES1370", |
d = (PCIES1370State *) pci_register_device (bus, "ES1370", |
| 982 |
sizeof (PCIES1370State), |
sizeof (PCIES1370State), |
| 983 |
-1, NULL, NULL); |
-1, NULL, NULL); |
| 1021 |
pci_register_io_region (&d->dev, 0, 256, PCI_ADDRESS_SPACE_IO, es1370_map); |
pci_register_io_region (&d->dev, 0, 256, PCI_ADDRESS_SPACE_IO, es1370_map); |
| 1022 |
register_savevm ("es1370", 0, 1, es1370_save, es1370_load, s); |
register_savevm ("es1370", 0, 1, es1370_save, es1370_load, s); |
| 1023 |
qemu_register_reset (es1370_on_reset, s); |
qemu_register_reset (es1370_on_reset, s); |
| 1024 |
|
|
| 1025 |
|
AUD_register_card (audio, "es1370", &s->card); |
| 1026 |
es1370_reset (s); |
es1370_reset (s); |
| 1027 |
return 0; |
return 0; |
| 1028 |
} |
} |