summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2018-05-25 22:28:49 +1000
committer Vas Crabb <vas@vastheman.com>2018-05-25 22:28:49 +1000
commit106e27478414a80e0959be52e55b23742855646c (patch)
treebaff6778e3449f8f9f7fb33a6935eaeb0bc5f255 /src/devices/sound
parentfada3dfc8b58b1209c6dcd4cf7837b4d23c88d82 (diff)
remove many mainly PCI-related MCFG macros in favour of constructor
overloads, remove some absolute device lookups, remove some absolute device tags, and generally clean up stuff fix incorrect device class for PCI APIC (nw) xbox machine config looks ugly now - the devices should expose proper constructor overloads that accept the parts of the PCI ID that are in system PROM or customisable by the OEM and hard-code the parts inherent to the device
Diffstat (limited to 'src/devices/sound')
-rw-r--r--src/devices/sound/es1373.cpp26
-rw-r--r--src/devices/sound/es1373.h17
-rw-r--r--src/devices/sound/pci-ac97.h8
-rw-r--r--src/devices/sound/sb0400.h8
4 files changed, 27 insertions, 32 deletions
diff --git a/src/devices/sound/es1373.cpp b/src/devices/sound/es1373.cpp
index b9ba7200955..6d5ccbaf027 100644
--- a/src/devices/sound/es1373.cpp
+++ b/src/devices/sound/es1373.cpp
@@ -84,17 +84,17 @@ 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_cpu_tag(nullptr), m_cpu(nullptr),
- m_irq_num(-1)
+ : 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)
{
+ set_ids(0x12741371, 0x04, 0x040100, 0x12741371);
}
-void es1373_device::set_irq_info(const char *tag, const int irq_num)
+void es1373_device::device_resolve_objects()
{
- m_cpu_tag = tag;
- m_irq_num = irq_num;
+ pci_device::device_resolve_objects();
+ m_irq_handler.resolve_safe();
}
//-------------------------------------------------
@@ -115,7 +115,6 @@ void es1373_device::device_stop()
//-------------------------------------------------
void es1373_device::device_start()
{
- m_cpu = machine().device<cpu_device>(m_cpu_tag);
pci_device::device_start();
add_map(0x40, M_IO, FUNC(es1373_device::map));
@@ -169,11 +168,11 @@ void es1373_device::device_start()
save_item(NAME(m_adc.pci_addr));
save_item(NAME(m_adc.pci_count));
save_item(NAME(m_adc.pci_size));
- machine().save().register_postload(save_prepost_delegate(FUNC(es1373_device::postload), this));
}
-void es1373_device::postload()
+void es1373_device::device_post_load()
{
+ pci_device::device_post_load();
remap_cb();
}
@@ -285,10 +284,7 @@ void es1373_device::sound_stream_update(sound_stream &stream, stream_sample_t **
if (m_es_regs[ES_INT_CS_STATUS]&(ICSTATUS_DAC1_INT_MASK|ICSTATUS_DAC2_INT_MASK|ICSTATUS_ADC_INT_MASK)) {
m_es_regs[ES_INT_CS_STATUS] |= ICSTATUS_INTR_MASK;
// Assert interrupt
- //m_cpu->set_input_line(ES_IRQ_NUM, ASSERT_LINE);
- if (m_irq_num!=-1) {
- m_cpu->set_input_line(m_irq_num, ASSERT_LINE);
- }
+ m_irq_handler(1);
}
}
@@ -536,7 +532,7 @@ WRITE32_MEMBER(es1373_device::reg_w)
if (!(m_es_regs[ES_INT_CS_STATUS]&(ICSTATUS_DAC1_INT_MASK|ICSTATUS_DAC2_INT_MASK|ICSTATUS_ADC_INT_MASK))) {
// Deassert interrupt
if (m_es_regs[ES_INT_CS_STATUS]&ICSTATUS_INTR_MASK && m_irq_num!=-1) {
- m_cpu->set_input_line(m_irq_num, CLEAR_LINE);
+ 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());
diff --git a/src/devices/sound/es1373.h b/src/devices/sound/es1373.h
index bb07d72afd0..a2705cba287 100644
--- a/src/devices/sound/es1373.h
+++ b/src/devices/sound/es1373.h
@@ -1,7 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Ted Green
// Creative Labs Ensonic AudioPCI97 ES1373
-
#ifndef MAME_SOUND_ES1373_H
#define MAME_SOUND_ES1373_H
@@ -9,12 +8,8 @@
#include "machine/pci.h"
-// No interrupts
-#define MCFG_ES1373_ADD(_tag) \
- MCFG_PCI_DEVICE_ADD(_tag, ES1373, 0x12741371, 0x04, 0x040100, 0x12741371)
-
-#define MCFG_ES1373_IRQ_ADD(_cpu_tag, _irq_num) \
- downcast<es1373_device *>(device)->set_irq_info(_cpu_tag, _irq_num);
+#define MCFG_ES1373_IRQ_HANDLER(cb) \
+ devcb = &downcast<es1373_device &>(*device).set_irq_handler(DEVCB_##cb);
class es1373_device : public pci_device, public device_sound_interface
{
@@ -24,18 +19,19 @@ public:
virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;
- void set_irq_info(const char *tag, const int irq_num);
- void postload(void);
+ template <typename T> devcb_base &set_irq_handler(T &&cb) { return m_irq_handler.set_callback(std::forward<T>(cb)); }
DECLARE_READ32_MEMBER (reg_r);
DECLARE_WRITE32_MEMBER(reg_w);
protected:
+ virtual void device_resolve_objects() override;
virtual void device_start() override;
virtual void device_stop() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_post_load() override;
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
// Sound stream
@@ -67,8 +63,7 @@ private:
uint32_t m_tempCount;
emu_timer *m_timer;
address_space *m_memory_space;
- const char *m_cpu_tag;
- cpu_device *m_cpu;
+ devcb_write_line m_irq_handler;
int m_irq_num;
void map(address_map &map);
uint16_t m_ac97_regs[0x80];
diff --git a/src/devices/sound/pci-ac97.h b/src/devices/sound/pci-ac97.h
index 85f6df08bfe..4633337e6dc 100644
--- a/src/devices/sound/pci-ac97.h
+++ b/src/devices/sound/pci-ac97.h
@@ -7,11 +7,13 @@
#include "machine/pci.h"
-#define MCFG_AC97_ADD(_tag, _main_id, _revision, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, AC97, _main_id, _revision, 0x040300, _subdevice_id)
-
class ac97_device : public pci_device {
public:
+ ac97_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t main_id, uint32_t revision, uint32_t subdevice_id)
+ : ac97_device(mconfig, tag, owner, clock)
+ {
+ set_ids(main_id, revision, 0x040300, subdevice_id);
+ }
ac97_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
diff --git a/src/devices/sound/sb0400.h b/src/devices/sound/sb0400.h
index 2cf2fac1cc0..440e82a0544 100644
--- a/src/devices/sound/sb0400.h
+++ b/src/devices/sound/sb0400.h
@@ -7,11 +7,13 @@
#include "machine/pci.h"
-#define MCFG_SB0400_ADD(_tag, _subdevice_id) \
- MCFG_PCI_DEVICE_ADD(_tag, SB0400, 0x11020008, 0x00, 0x040100, _subdevice_id)
-
class sb0400_device : public pci_device {
public:
+ sb0400_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subdevice_id)
+ : sb0400_device(mconfig, tag, owner, clock)
+ {
+ set_ids(0x11020008, 0x00, 0x040100, subdevice_id);
+ }
sb0400_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected: