1 // license:BSD-3-Clause 2 // copyright-holders:Ted Green 3 // Creative Labs Ensonic AudioPCI97 ES1373 4 #ifndef MAME_SOUND_ES1373_H 5 #define MAME_SOUND_ES1373_H 6 7 #pragma once 8 9 #include "machine/pci.h" 10 11 class es1373_device : public pci_device, public device_sound_interface 12 { 13 public: 14 es1373_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 15 16 virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space, 17 uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override; 18 irq_handler()19 auto irq_handler() { return m_irq_handler.bind(); } 20 21 uint32_t reg_r(offs_t offset, uint32_t mem_mask = ~0); 22 void reg_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 23 24 protected: 25 virtual void device_resolve_objects() override; 26 virtual void device_start() override; 27 virtual void device_stop() override; 28 virtual void device_reset() override; 29 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 30 virtual void device_add_mconfig(machine_config &config) override; 31 virtual void device_post_load() override; 32 virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; 33 34 // Sound stream 35 sound_stream *m_stream; 36 37 FILE *m_eslog; 38 39 private: 40 struct chan_info { 41 int number; 42 bool enable; 43 bool int_en; 44 bool loop_en; 45 bool initialized; 46 uint8_t format; // Format of channel 47 uint32_t buf_wptr; // Address to sample cache memory 48 uint32_t buf_rptr; // Address to sample cache memory 49 uint16_t buf_count; // Number of samples that have been played 50 uint16_t buf_size; // Number of samples minus one to play 51 uint32_t pci_addr; // PCI Address for system memory accesses 52 uint16_t pci_count; // Number of 32 bits transferred 53 uint16_t pci_size; // Total number of words (32 bits) minus one in system memory 54 }; 55 56 void transfer_pci_audio(chan_info& chan, int type); 57 uint32_t calc_size(const uint8_t &format); 58 void send_audio_out(chan_info& chan, uint32_t intr_mask, write_stream_view &outL, write_stream_view &outR); 59 60 uint32_t m_tempCount; 61 emu_timer *m_timer; 62 address_space *m_memory_space; 63 devcb_write_line m_irq_handler; 64 int m_irq_num; 65 void map(address_map &map); 66 uint16_t m_ac97_regs[0x80]; 67 uint32_t m_es_regs[0x10]; 68 uint32_t m_sound_cache[0x40]; 69 uint16_t m_src_ram[0x80]; 70 chan_info m_dac1; 71 chan_info m_dac2; 72 chan_info m_adc; 73 }; 74 75 DECLARE_DEVICE_TYPE(ES1373, es1373_device) 76 77 #endif // MAME_SOUND_ES1373_H 78