diff options
Diffstat (limited to 'src/devices/sound/es1373.cpp')
-rw-r--r-- | src/devices/sound/es1373.cpp | 165 |
1 files changed, 62 insertions, 103 deletions
diff --git a/src/devices/sound/es1373.cpp b/src/devices/sound/es1373.cpp index dbc0c6a96d8..c3b88ecac49 100644 --- a/src/devices/sound/es1373.cpp +++ b/src/devices/sound/es1373.cpp @@ -6,9 +6,16 @@ #include "speaker.h" -#define LOG_ES (0) -#define LOG_ES_REG (0) -#define LOG_ES_FILE (0) +#define LOG_OTHER (1U << 1) +#define LOG_REG (1U << 2) +#define LOG_IRQ (1U << 3) +#define LOG_ADC (1U << 4) +#define LOG_INVALID (1U << 5) +#define LOG_UNIMPL (1U << 6) +#define LOG_SAMPLES (1U << 7) + +#define VERBOSE (LOG_UNIMPL | LOG_INVALID) +#include "logmacro.h" /* Ensonic ES1373 registers 0x00-0x3f */ @@ -73,8 +80,7 @@ void es1373_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } DEFINE_DEVICE_TYPE(ES1373, es1373_device, "es1373", "Creative Labs Ensoniq AudioPCI97 ES1373") @@ -87,30 +93,11 @@ void es1373_device::map(address_map &map) es1373_device::es1373_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : pci_device(mconfig, ES1373, tag, owner, clock) , device_sound_interface(mconfig, *this), m_stream(nullptr) - , m_eslog(nullptr), m_tempCount(0), m_timer(nullptr), m_memory_space(nullptr), m_irq_handler(*this) + , m_timer(nullptr), m_memory_space(nullptr), m_irq_handler(*this) { set_ids(0x12741371, 0x04, 0x040100, 0x12741371); } -void es1373_device::device_resolve_objects() -{ - pci_device::device_resolve_objects(); - m_irq_handler.resolve_safe(); -} - -//------------------------------------------------- -// device_stop - device-specific stop -//------------------------------------------------- -void es1373_device::device_stop() -{ - /* debugging */ - if (LOG_ES_FILE && m_eslog) - { - fclose(m_eslog); - m_eslog = nullptr; - } -} - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -120,9 +107,9 @@ void es1373_device::device_start() add_map(0x40, M_IO, FUNC(es1373_device::map)); // create the stream - m_stream = machine().sound().stream_alloc(*this, 0, 2, 44100/2); + m_stream = stream_alloc(0, 2, 44100/2); - m_timer = timer_alloc(0, nullptr); + m_timer = timer_alloc(FUNC(es1373_device::delayed_stream_update), this); m_timer->adjust(attotime::zero, 0, attotime::from_hz(44100/2/16)); // Save states @@ -179,16 +166,6 @@ void es1373_device::device_post_load() void es1373_device::device_reset() { - // debugging - m_tempCount = 0; - if (LOG_ES_FILE && m_eslog) - { - fclose(m_eslog); - m_eslog = nullptr; - } - if (LOG_ES_FILE && !m_eslog) - m_eslog = fopen("es.log", "w"); - pci_device::device_reset(); memset(m_es_regs, 0, sizeof(m_es_regs)); memset(m_ac97_regs, 0, sizeof(m_ac97_regs)); @@ -222,9 +199,9 @@ void es1373_device::map_extra(uint64_t memory_window_start, uint64_t memory_wind } //------------------------------------------------- -// device_timer - called when our device timer expires +// delayed_stream_update - //------------------------------------------------- -void es1373_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) +TIMER_CALLBACK_MEMBER(es1373_device::delayed_stream_update) { m_stream->update(); } @@ -233,25 +210,24 @@ void es1373_device::device_timer(emu_timer &timer, device_timer_id tid, int para // sound_stream_update - handle update requests for // our sound stream //------------------------------------------------- -void es1373_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +void es1373_device::sound_stream_update(sound_stream &stream) { if (m_dac1.enable) { - logerror("%s: sound_stream_update DAC1 not implemented yet\n", tag()); + LOGMASKED(LOG_UNIMPL, "%s: sound_stream_update DAC1 not implemented yet\n", tag()); } if (m_dac2.enable) { - send_audio_out(m_dac2, ICSTATUS_DAC2_INT_MASK, outputs[0], outputs[1], samples); + send_audio_out(m_dac2, ICSTATUS_DAC2_INT_MASK, stream); } if (m_adc.enable) { if (m_adc.format!=SCTRL_16BIT_MONO) { - logerror("%s: sound_stream_update Only SCTRL_16BIT_MONO recorded supported\n", tag()); + LOGMASKED(LOG_UNIMPL, "%s: sound_stream_update Only SCTRL_16BIT_MONO recorded supported\n", tag()); } else { - for (int i=0; i<samples; i++) { + for (int i=0; i<stream.samples(); i++) { if (m_adc.buf_count<=m_adc.buf_size) { - if (LOG_ES) - logerror("%s: ADC buf_count: %i buf_size: %i buf_rptr: %i buf_wptr: %i\n", machine().describe_context(), - m_adc.buf_count, m_adc.buf_size, m_adc.buf_rptr, m_adc.buf_wptr); + LOGMASKED(LOG_OTHER, "%s: ADC buf_count: %i buf_size: %i buf_rptr: %i buf_wptr: %i\n", machine().describe_context(), + m_adc.buf_count, m_adc.buf_size, m_adc.buf_rptr, m_adc.buf_wptr); if ((m_adc.buf_count&0x1)) { m_adc.buf_wptr++; } @@ -260,13 +236,11 @@ void es1373_device::sound_stream_update(sound_stream &stream, stream_sample_t ** if (m_adc.loop_en) { // Keep playing m_adc.buf_count = 0; - if (LOG_ES) - logerror("%s: send_audio_out ADC clearing buf_count\n", machine().describe_context()); + LOGMASKED(LOG_OTHER, "%s: send_audio_out ADC clearing buf_count\n", machine().describe_context()); } if (m_adc.int_en) { m_es_regs[ES_INT_CS_STATUS] |= ICSTATUS_ADC_INT_MASK; - if (LOG_ES) - logerror("%s: send_audio_out Setting ADC interrupt\n", machine().describe_context()); + LOGMASKED(LOG_OTHER, "%s: send_audio_out Setting ADC interrupt\n", machine().describe_context()); } } if (!(m_adc.buf_count&1) && !(m_adc.buf_wptr&0xf)) { @@ -292,7 +266,7 @@ void es1373_device::sound_stream_update(sound_stream &stream, stream_sample_t ** //------------------------------------------------- // send_audio_out - Sends channel audio output data //------------------------------------------------- -void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, stream_sample_t *outL, stream_sample_t *outR, int samples) +void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, sound_stream &stream) { // Only transfer PCI data if bus mastering is enabled // Fill initial half buffer @@ -303,8 +277,9 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, stream_s //uint32_t sample_size = calc_size(chan.format); // Send data to sound stream bool buf_row_done; - for (int i=0; i<samples; i++) { + for (int i=0; i<stream.samples(); i++) { buf_row_done = false; + int16_t lsamp = 0, rsamp = 0; if (chan.buf_count<=chan.buf_size) { // Only transfer PCI data if bus mastering is enabled // Fill half-buffer when read pointer is at start of next half @@ -312,42 +287,36 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, stream_s if ((command & 0x4) && ((chan.buf_rptr&8)^(chan.buf_wptr&8))) { transfer_pci_audio(chan, ES_PCI_READ); } - if (LOG_ES && i==0) - logerror("%s: chan: %X samples: %i buf_count: %X buf_size: %X buf_rptr: %X buf_wptr: %X\n", - machine().describe_context(), chan.number, samples, chan.buf_count, chan.buf_size, chan.buf_rptr, chan.buf_wptr); + if (i == 0) + LOGMASKED(LOG_OTHER, "%s: chan: %X samples: %i buf_count: %X buf_size: %X buf_rptr: %X buf_wptr: %X\n", + machine().describe_context(), chan.number, stream.samples(), chan.buf_count, chan.buf_size, chan.buf_rptr, chan.buf_wptr); // Buffer is 4 bytes per location, need to switch on sample mode switch (chan.format) { case SCTRL_8BIT_MONO: - logerror("es1373_device::send_audio_out SCTRL_8BIT_MONO not implemented yet\n"); + LOGMASKED(LOG_UNIMPL, "es1373_device::send_audio_out SCTRL_8BIT_MONO not implemented yet\n"); break; case SCTRL_8BIT_STEREO: - logerror("es1373_device::send_audio_out SCTRL_8BIT_STEREO not implemented yet\n"); + LOGMASKED(LOG_UNIMPL, "es1373_device::send_audio_out SCTRL_8BIT_STEREO not implemented yet\n"); break; case SCTRL_16BIT_MONO: - // The sound cache is 32 bit wide fifo, so each entry is two mono 16 bit samples - if ((chan.buf_count&0x1)) { - // Read high 16 bits - outL[i] = outR[i] = (int16_t)(m_sound_cache[chan.buf_rptr]>>16); - chan.buf_rptr++; - buf_row_done = true; - } else { - // Read low 16 bits - outL[i] = outR[i] = (int16_t)(m_sound_cache[chan.buf_rptr]&0xffff); - } - break; - case SCTRL_16BIT_STEREO: - // The sound cache is 32 bit wide fifo, so each entry is one stereo 16 bit sample - outL[i] = (int16_t) m_sound_cache[chan.buf_rptr]&0xffff; - outR[i] = (int16_t) m_sound_cache[chan.buf_rptr]>>16; + // The sound cache is 32 bit wide fifo, so each entry is two mono 16 bit samples + if ((chan.buf_count&0x1)) { + // Read high 16 bits + lsamp = rsamp = m_sound_cache[chan.buf_rptr]>>16; chan.buf_rptr++; buf_row_done = true; + } else { + // Read low 16 bits + lsamp = rsamp = m_sound_cache[chan.buf_rptr]&0xffff; + } + break; + case SCTRL_16BIT_STEREO: + // The sound cache is 32 bit wide fifo, so each entry is one stereo 16 bit sample + lsamp = m_sound_cache[chan.buf_rptr]&0xffff; + rsamp = m_sound_cache[chan.buf_rptr]>>16; + chan.buf_rptr++; + buf_row_done = true; break; - } - if (LOG_ES_FILE && m_tempCount<1000000) { - m_tempCount++; - //logerror("es1373_device::sound_stream_update count: %i samp16: %X\n", i, samp16); - //if (LOG_ES_FILE && m_eslog) - //fprintf(m_eslog, "%i\n", samp16); } chan.buf_count++; if (chan.buf_count > chan.buf_size) { @@ -356,22 +325,19 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, stream_s //chan.buf_count -= 1; // Should check SCTRL_P2_END_MASK chan.buf_count = 0; //chan.buf_rptr -= 1; - if (LOG_ES) - logerror("%s: send_audio_out DAC2 clearing buf_count\n", machine().describe_context()); + LOGMASKED(LOG_OTHER, "%s: send_audio_out DAC2 clearing buf_count\n", machine().describe_context()); } if (chan.int_en) { m_es_regs[ES_INT_CS_STATUS] |= intr_mask; - if (LOG_ES) - logerror("%s: send_audio_out Setting DAC2 interrupt\n", machine().describe_context()); + LOGMASKED(LOG_OTHER, "%s: send_audio_out Setting DAC2 interrupt\n", machine().describe_context()); } } if (buf_row_done && !(chan.buf_rptr&0xf)) { chan.buf_rptr -= 0x10; } - } else { - // Send zeros? - outL[i] = outR[i] = 0; } + stream.put_int(0, i, lsamp, 32768); + stream.put_int(1, i, rsamp, 32768); } } @@ -379,9 +345,8 @@ void es1373_device::transfer_pci_audio(chan_info& chan, int type) { uint32_t pci_addr, data; pci_addr = chan.pci_addr + (chan.pci_count<<2); - if (LOG_ES) - logerror("%s: transfer_pci_audio start chan: %X pci_addr: %08X pci_count: %X pci_size: %X buf_rptr: %X buf_wptr: %X\n", - machine().describe_context(), chan.number, pci_addr, chan.pci_count, chan.pci_size, chan.buf_rptr, chan.buf_wptr); + LOGMASKED(LOG_OTHER, "%s: transfer_pci_audio start chan: %X pci_addr: %08X pci_count: %X pci_size: %X buf_rptr: %X buf_wptr: %X\n", + machine().describe_context(), chan.number, pci_addr, chan.pci_count, chan.pci_size, chan.buf_rptr, chan.buf_wptr); // Always transfer 8 longwords for (int i=0; i<8; i++) { pci_addr = chan.pci_addr + (chan.pci_count<<2); @@ -422,11 +387,11 @@ uint32_t es1373_device::calc_size(const uint8_t &format) return 4; break; } - logerror("%s: calc_size Invalid format = %X specified\n", tag(), format); + LOGMASKED(LOG_INVALID, "%s: calc_size Invalid format = %X specified\n", tag(), format); return 0; } -READ32_MEMBER (es1373_device::reg_r) +uint32_t es1373_device::reg_r(offs_t offset, uint32_t mem_mask) { uint32_t result = m_es_regs[offset]; switch (offset) { @@ -484,12 +449,11 @@ READ32_MEMBER (es1373_device::reg_r) default: break; } - if (LOG_ES_REG) - logerror("%s:ES1373 read from offset %02X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); + LOGMASKED(LOG_REG, "%s:ES1373 read from offset %02X = %08X & %08X\n", machine().describe_context(), offset*4, result, mem_mask); return result; } -WRITE32_MEMBER(es1373_device::reg_w) +void es1373_device::reg_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_es_regs[offset]); switch (offset) { @@ -535,12 +499,10 @@ WRITE32_MEMBER(es1373_device::reg_w) if (m_es_regs[ES_INT_CS_STATUS]&ICSTATUS_INTR_MASK && m_irq_num!=-1) { m_irq_handler(0); m_es_regs[ES_INT_CS_STATUS] &= ~ICSTATUS_INTR_MASK; - if (0 && LOG_ES_REG) - logerror("%s: es1373_device::reg_w Clearing interrupt\n", machine().describe_context()); + LOGMASKED(LOG_IRQ, "%s: es1373_device::reg_w Clearing interrupt\n", machine().describe_context()); } } - if (0 && LOG_ES_REG) - logerror("%s: es1373_device::reg_w adc_int_en: %i dac1_int_en: %i dac2_int_en: %i\n", tag(), m_adc.int_en, m_dac1.int_en, m_dac2.int_en); + LOGMASKED(LOG_ADC, "%s: es1373_device::reg_w adc_int_en: %i dac1_int_en: %i dac2_int_en: %i\n", tag(), m_adc.int_en, m_dac1.int_en, m_dac2.int_en); break; case ES_DAC2_CNT: m_dac2.buf_count = 0; @@ -590,8 +552,7 @@ WRITE32_MEMBER(es1373_device::reg_w) case 0xc: m_dac2.pci_count = (data>>16)&0xffff; m_dac2.pci_size = data&0xffff; - if (LOG_ES_REG) - logerror("%s:ES1373 write to offset %02X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); + LOGMASKED(LOG_REG, "%s:ES1373 write to offset %02X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); break; default: break; @@ -601,7 +562,5 @@ WRITE32_MEMBER(es1373_device::reg_w) break; } - if (LOG_ES_REG) - logerror("%s:ES1373 write to offset %02X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); - + LOGMASKED(LOG_REG, "%s:ES1373 write to offset %02X = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask); } |