diff --git a/hw/xbox/Makefile.objs b/hw/xbox/Makefile.objs index ce018cb898..6d5428d69b 100644 --- a/hw/xbox/Makefile.objs +++ b/hw/xbox/Makefile.objs @@ -3,13 +3,13 @@ obj-y += chihiro.o obj-y += xbox_pci.o acpi_xbox.o obj-y += amd_smbus.o smbus_xbox_smc.o smbus_cx25871.o smbus_adm1032.o obj-y += nvnet.o -obj-y += mcpx_apu.o mcpx_aci.o +obj-y += mcpx_aci.o obj-y += lpc47m157.o obj-y += xid.o xid-sdl.o obj-y += chihiro-usb.o -obj-y += dsp/ obj-y += nv2a/ +obj-y += mcpx_apu/ xid-sdl.o-cflags := $(SDL_CFLAGS) xid-sdl.o-libs := $(SDL_LIBS) diff --git a/hw/xbox/mcpx_apu/Makefile.objs b/hw/xbox/mcpx_apu/Makefile.objs new file mode 100644 index 0000000000..80870e0963 --- /dev/null +++ b/hw/xbox/mcpx_apu/Makefile.objs @@ -0,0 +1,3 @@ +obj-y += mcpx_apu.o + +obj-y += dsp/ diff --git a/hw/xbox/dsp/Makefile.objs b/hw/xbox/mcpx_apu/dsp/Makefile.objs similarity index 100% rename from hw/xbox/dsp/Makefile.objs rename to hw/xbox/mcpx_apu/dsp/Makefile.objs diff --git a/hw/xbox/dsp/dsp.c b/hw/xbox/mcpx_apu/dsp/dsp.c similarity index 100% rename from hw/xbox/dsp/dsp.c rename to hw/xbox/mcpx_apu/dsp/dsp.c diff --git a/hw/xbox/dsp/dsp.h b/hw/xbox/mcpx_apu/dsp/dsp.h similarity index 100% rename from hw/xbox/dsp/dsp.h rename to hw/xbox/mcpx_apu/dsp/dsp.h diff --git a/hw/xbox/dsp/dsp_cpu.c b/hw/xbox/mcpx_apu/dsp/dsp_cpu.c similarity index 100% rename from hw/xbox/dsp/dsp_cpu.c rename to hw/xbox/mcpx_apu/dsp/dsp_cpu.c diff --git a/hw/xbox/dsp/dsp_cpu.h b/hw/xbox/mcpx_apu/dsp/dsp_cpu.h similarity index 100% rename from hw/xbox/dsp/dsp_cpu.h rename to hw/xbox/mcpx_apu/dsp/dsp_cpu.h diff --git a/hw/xbox/dsp/dsp_dis.inl b/hw/xbox/mcpx_apu/dsp/dsp_dis.inl similarity index 100% rename from hw/xbox/dsp/dsp_dis.inl rename to hw/xbox/mcpx_apu/dsp/dsp_dis.inl diff --git a/hw/xbox/dsp/dsp_dma.c b/hw/xbox/mcpx_apu/dsp/dsp_dma.c similarity index 100% rename from hw/xbox/dsp/dsp_dma.c rename to hw/xbox/mcpx_apu/dsp/dsp_dma.c diff --git a/hw/xbox/dsp/dsp_dma.h b/hw/xbox/mcpx_apu/dsp/dsp_dma.h similarity index 100% rename from hw/xbox/dsp/dsp_dma.h rename to hw/xbox/mcpx_apu/dsp/dsp_dma.h diff --git a/hw/xbox/dsp/dsp_emu.inl b/hw/xbox/mcpx_apu/dsp/dsp_emu.inl similarity index 100% rename from hw/xbox/dsp/dsp_emu.inl rename to hw/xbox/mcpx_apu/dsp/dsp_emu.inl diff --git a/hw/xbox/mcpx_apu.c b/hw/xbox/mcpx_apu/mcpx_apu.c similarity index 95% rename from hw/xbox/mcpx_apu.c rename to hw/xbox/mcpx_apu/mcpx_apu.c index 58b643f574..94f8afa103 100644 --- a/hw/xbox/mcpx_apu.c +++ b/hw/xbox/mcpx_apu/mcpx_apu.c @@ -1,5 +1,5 @@ /* - * QEMU MCPX Audio Processing Unit implementation + * QEMU MCPX APU implementation * * Copyright (c) 2012 espes * Copyright (c) 2018-2019 Jannik Vogel @@ -23,13 +23,15 @@ #include "hw/i386/pc.h" #include "hw/pci/pci.h" #include "cpu.h" -#include "hw/xbox/dsp/dsp.h" +#include "hw/xbox/mcpx_apu/dsp/dsp.h" #include #define NUM_SAMPLES_PER_FRAME 32 #define NUM_MIXBINS 32 -#include "hw/xbox/mcpx_apu.h" +#include "mcpx_apu_debug.h" + +#include "hw/xbox/mcpx_apu/mcpx_apu.h" #define NV_PAPU_ISTS 0x00001000 # define NV_PAPU_ISTS_GINTSTS (1 << 0) @@ -181,16 +183,6 @@ static const struct { (v) |= ((val) << ctz32(mask)) & (mask); \ } while (0) -// #define MCPX_DEBUG -#ifdef MCPX_DEBUG -# define MCPX_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) -#else -# define MCPX_DPRINTF(format, ...) do { } while (0) -#endif - -/* More debug functionality */ -#define GENERATE_MIXBIN_BEEP 0 - typedef struct MCPXAPUState { PCIDevice dev; @@ -262,11 +254,11 @@ static void update_irq(MCPXAPUState *d) & d->regs[NV_PAPU_IEN])) { d->regs[NV_PAPU_ISTS] |= NV_PAPU_ISTS_GINTSTS; - MCPX_DPRINTF("mcpx irq raise\n"); + MCPX_APU_DPRINTF("mcpx irq raise\n"); pci_irq_assert(&d->dev); } else { d->regs[NV_PAPU_ISTS] &= ~NV_PAPU_ISTS_GINTSTS; - MCPX_DPRINTF("mcpx irq lower\n"); + MCPX_APU_DPRINTF("mcpx irq lower\n"); pci_irq_deassert(&d->dev); } } @@ -288,7 +280,7 @@ static uint64_t mcpx_apu_read(void *opaque, break; } - MCPX_DPRINTF("mcpx apu: read [0x%llx] -> 0x%llx\n", addr, r); + MCPX_APU_DPRINTF("mcpx apu: read [0x%llx] -> 0x%llx\n", addr, r); return r; } @@ -297,7 +289,7 @@ static void mcpx_apu_write(void *opaque, hwaddr addr, { MCPXAPUState *d = opaque; - MCPX_DPRINTF("mcpx apu: [0x%llx] = 0x%llx\n", addr, val); + MCPX_APU_DPRINTF("mcpx apu: [0x%llx] = 0x%llx\n", addr, val); switch (addr) { case NV_PAPU_ISTS: @@ -338,7 +330,7 @@ static const MemoryRegionOps mcpx_apu_mmio_ops = { static void fe_method(MCPXAPUState *d, uint32_t method, uint32_t argument) { - MCPX_DPRINTF("mcpx fe_method 0x%x 0x%x\n", method, argument); + MCPX_APU_DPRINTF("mcpx fe_method 0x%x 0x%x\n", method, argument); //assert((d->regs[NV_PAPU_FECTL] & NV_PAPU_FECTL_FEMETHMODE) == 0); @@ -422,7 +414,7 @@ static void fe_method(MCPXAPUState *d, static uint64_t vp_read(void *opaque, hwaddr addr, unsigned int size) { - MCPX_DPRINTF("mcpx apu VP: read [0x%llx]\n", addr); + MCPX_APU_DPRINTF("mcpx apu VP: read [0x%llx]\n", addr); switch (addr) { case NV1BA0_PIO_FREE: /* we don't simulate the queue for now, @@ -439,7 +431,7 @@ static void vp_write(void *opaque, hwaddr addr, { MCPXAPUState *d = opaque; - MCPX_DPRINTF("mcpx apu VP: [0x%llx] = 0x%llx\n", addr, val); + MCPX_APU_DPRINTF("mcpx apu VP: [0x%llx] = 0x%llx\n", addr, val); switch (addr) { case NV1BA0_PIO_SET_ANTECEDENT_VOICE: @@ -540,7 +532,7 @@ static uint32_t circular_scatter_gather_rw(MCPXAPUState *d, bytes_to_copy = len; } - MCPX_DPRINTF("circular scatter gather %s in range 0x%x - 0x%x at 0x%x of length 0x%x / 0x%lx bytes\n", + MCPX_APU_DPRINTF("circular scatter gather %s in range 0x%x - 0x%x at 0x%x of length 0x%x / 0x%lx bytes\n", dir ? "write" : "read", base, end, cur, bytes_to_copy, len); assert((cur >= base) && ((cur + bytes_to_copy) <= end)); @@ -685,7 +677,7 @@ static uint64_t gp_read(void *opaque, r = d->gp.regs[addr]; break; } - MCPX_DPRINTF("mcpx apu GP: read [0x%llx] -> 0x%llx\n", addr, r); + MCPX_APU_DPRINTF("mcpx apu GP: read [0x%llx] -> 0x%llx\n", addr, r); return r; } @@ -697,7 +689,7 @@ static void gp_write(void *opaque, hwaddr addr, assert(size == 4); assert(addr % 4 == 0); - MCPX_DPRINTF("mcpx apu GP: [0x%llx] = 0x%llx\n", addr, val); + MCPX_APU_DPRINTF("mcpx apu GP: [0x%llx] = 0x%llx\n", addr, val); switch (addr) { case NV_PAPU_GPXMEM ... NV_PAPU_GPXMEM + 0x1000 * 4 - 1: { @@ -766,7 +758,7 @@ static uint64_t ep_read(void *opaque, r = d->ep.regs[addr]; break; } - MCPX_DPRINTF("mcpx apu EP: read [0x%llx] -> 0x%llx\n", addr, r); + MCPX_APU_DPRINTF("mcpx apu EP: read [0x%llx] -> 0x%llx\n", addr, r); return r; } @@ -778,7 +770,7 @@ static void ep_write(void *opaque, hwaddr addr, assert(size == 4); assert(addr % 4 == 0); - MCPX_DPRINTF("mcpx apu EP: [0x%llx] = 0x%llx\n", addr, val); + MCPX_APU_DPRINTF("mcpx apu EP: [0x%llx] = 0x%llx\n", addr, val); switch (addr) { case NV_PAPU_EPXMEM ... NV_PAPU_EPXMEM + 0xC00 * 4 - 1: { @@ -827,7 +819,7 @@ static void se_frame(void *opaque) int sample; timer_mod(d->se.frame_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 10); - MCPX_DPRINTF("mcpx frame ping\n"); + MCPX_APU_DPRINTF("mcpx frame ping\n"); /* Buffer for all mixbins for this frame */ int32_t mixbins[NUM_MIXBINS][NUM_SAMPLES_PER_FRAME] = { 0 }; @@ -841,7 +833,7 @@ static void se_frame(void *opaque) next = voice_list_regs[list].next; d->regs[current] = d->regs[top]; - MCPX_DPRINTF("list %d current voice %d\n", list, d->regs[current]); + MCPX_APU_DPRINTF("list %d current voice %d\n", list, d->regs[current]); while (d->regs[current] != 0xFFFF) { d->regs[next] = voice_get_mask(d, d->regs[current], NV_PAVS_VOICE_TAR_PITCH_LINK, @@ -849,12 +841,12 @@ static void se_frame(void *opaque) if (!voice_get_mask(d, d->regs[current], NV_PAVS_VOICE_PAR_STATE, NV_PAVS_VOICE_PAR_STATE_ACTIVE_VOICE)) { - MCPX_DPRINTF("voice %d not active...!\n", d->regs[current]); + MCPX_APU_DPRINTF("voice %d not active...!\n", d->regs[current]); fe_method(d, SE2FE_IDLE_VOICE, d->regs[current]); } else { process_voice(d, mixbins, d->regs[current]); } - MCPX_DPRINTF("next voice %d\n", d->regs[next]); + MCPX_APU_DPRINTF("next voice %d\n", d->regs[next]); d->regs[current] = d->regs[next]; } } diff --git a/hw/xbox/mcpx_apu.h b/hw/xbox/mcpx_apu/mcpx_apu.h similarity index 95% rename from hw/xbox/mcpx_apu.h rename to hw/xbox/mcpx_apu/mcpx_apu.h index 6c6fc484b3..c1569d6b50 100644 --- a/hw/xbox/mcpx_apu.h +++ b/hw/xbox/mcpx_apu/mcpx_apu.h @@ -1,5 +1,5 @@ /* - * QEMU Geforce NV2A implementation + * QEMU MCPX APU implementation * * Copyright (c) 2018 Jannik Vogel * diff --git a/hw/xbox/mcpx_apu/mcpx_apu_debug.h b/hw/xbox/mcpx_apu/mcpx_apu_debug.h new file mode 100644 index 0000000000..1270f49c10 --- /dev/null +++ b/hw/xbox/mcpx_apu/mcpx_apu_debug.h @@ -0,0 +1,34 @@ +/* + * QEMU MCPX APU debug helpers + * + * Copyright (c) 2012 espes + * Copyright (c) 2019 Jannik Vogel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef HW_MCPX_APU_DEBUG_H +#define HW_MCPX_APU_DEBUG_H + +// #define DEBUG_MCPX_APU +#ifdef DEBUG_MCPX_APU +# define MCPX_APU_DPRINTF(format, ...) printf("mcpx-apu: " format, ## __VA_ARGS__) +#else +# define MCPX_APU_DPRINTF(format, ...) do { } while (0) +#endif + +/* Generate a tone in the MIXBIN for every channel */ +#define GENERATE_MIXBIN_BEEP 0 + +#endif diff --git a/hw/xbox/xbox.c b/hw/xbox/xbox.c index d2b285b2d2..1586ed00f9 100644 --- a/hw/xbox/xbox.c +++ b/hw/xbox/xbox.c @@ -47,7 +47,7 @@ #include "hw/xbox/xbox_pci.h" #include "hw/xbox/smbus.h" #include "hw/xbox/nv2a/nv2a.h" -#include "hw/xbox/mcpx_apu.h" +#include "hw/xbox/mcpx_apu/mcpx_apu.h" #include "hw/xbox/xbox.h"