mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-12-25 03:29:38 +00:00
Initial AWACS sound device emulation.
This commit is contained in:
parent
9be3250142
commit
751efb4cd6
83
devices/awacs.cpp
Normal file
83
devices/awacs.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
|
Copyright (C) 2018-20 divingkatae and maximum
|
||||||
|
(theweirdo) spatium
|
||||||
|
|
||||||
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** AWAC sound device emulation.
|
||||||
|
|
||||||
|
Author: Max Poliakovski 2019-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <thirdparty/loguru.hpp>
|
||||||
|
#include "awacs.h"
|
||||||
|
#include "machines/machinebase.h"
|
||||||
|
|
||||||
|
AWACDevice::AWACDevice()
|
||||||
|
{
|
||||||
|
this->audio_proc = new AudioProcessor();
|
||||||
|
|
||||||
|
/* register audio processor chip with the I2C bus */
|
||||||
|
I2CBus *i2c_bus = dynamic_cast<I2CBus *>(gMachineObj->get_comp_by_type(HWCompType::I2C_HOST));
|
||||||
|
i2c_bus->register_device(0x45, this->audio_proc);
|
||||||
|
}
|
||||||
|
|
||||||
|
AWACDevice::~AWACDevice()
|
||||||
|
{
|
||||||
|
delete this->audio_proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t AWACDevice::snd_ctrl_read(uint32_t offset, int size)
|
||||||
|
{
|
||||||
|
switch(offset) {
|
||||||
|
case AWAC_SOUND_CTRL_REG:
|
||||||
|
return this->snd_ctrl_reg;
|
||||||
|
case AWAC_CODEC_CTRL_REG:
|
||||||
|
return this->is_busy;
|
||||||
|
case AWAC_CODEC_STATUS_REG:
|
||||||
|
return (AWAC_AVAILABLE << 8) | (AWAC_MAKER_CRYSTAL << 16) |
|
||||||
|
(AWAC_REV_SCREAMER << 20);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG_F(ERROR, "AWAC: unsupported register at offset 0x%X", offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AWACDevice::snd_ctrl_write(uint32_t offset, uint32_t value, int size)
|
||||||
|
{
|
||||||
|
int subframe, reg_num;
|
||||||
|
uint16_t data;
|
||||||
|
|
||||||
|
switch(offset) {
|
||||||
|
case AWAC_SOUND_CTRL_REG:
|
||||||
|
this->snd_ctrl_reg = value;
|
||||||
|
break;
|
||||||
|
case AWAC_CODEC_CTRL_REG:
|
||||||
|
subframe = (value >> 14) & 3;
|
||||||
|
reg_num = (value >> 20) & 7;
|
||||||
|
data = ((value >> 8) & 0xF00) | ((value >> 24) & 0xFF);
|
||||||
|
LOG_F(INFO, "AWAC subframe = %d, reg = %d, data = %08X\n", subframe, reg_num, data);
|
||||||
|
if (!subframe)
|
||||||
|
this->control_regs[reg_num] = data;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG_F(ERROR, "AWAC: unsupported register at offset 0x%X", offset);
|
||||||
|
}
|
||||||
|
}
|
117
devices/awacs.h
Normal file
117
devices/awacs.h
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
|
Copyright (C) 2018-20 divingkatae and maximum
|
||||||
|
(theweirdo) spatium
|
||||||
|
|
||||||
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** AWAC sound devices family definitions.
|
||||||
|
|
||||||
|
Audio Waveform Aplifier and Converter (AWAC) is a family of custom audio
|
||||||
|
chips used in Power Macintosh.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AWAC_H
|
||||||
|
#define AWAC_H
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include "i2c.h"
|
||||||
|
|
||||||
|
/** AWAC registers offsets. */
|
||||||
|
enum {
|
||||||
|
AWAC_SOUND_CTRL_REG = 0x00,
|
||||||
|
AWAC_CODEC_CTRL_REG = 0x10,
|
||||||
|
AWAC_CODEC_STATUS_REG = 0x20,
|
||||||
|
};
|
||||||
|
|
||||||
|
/** AWAC manufacturer and revision. */
|
||||||
|
#define AWAC_MAKER_CRYSTAL 1
|
||||||
|
#define AWAC_REV_SCREAMER 3
|
||||||
|
|
||||||
|
/** Apple source calls this kValidData but doesn't explain
|
||||||
|
what it actually means. It seems like it's used to check
|
||||||
|
if the sound codec is available.
|
||||||
|
*/
|
||||||
|
#define AWAC_AVAILABLE 0x40
|
||||||
|
|
||||||
|
|
||||||
|
/** Audio processor chip (TDA7433) emulation. */
|
||||||
|
class AudioProcessor : public I2CDevice {
|
||||||
|
public:
|
||||||
|
AudioProcessor() = default;
|
||||||
|
~AudioProcessor() = default;
|
||||||
|
|
||||||
|
void start_transaction() { this->pos = 0; };
|
||||||
|
|
||||||
|
bool send_subaddress(uint8_t sub_addr) {
|
||||||
|
if ((sub_addr & 0xF) > 6)
|
||||||
|
return false; /* invalid subaddress -> no acknowledge */
|
||||||
|
|
||||||
|
this->sub_addr = sub_addr & 0xF;
|
||||||
|
this->auto_inc = !!(sub_addr & 0x10);
|
||||||
|
LOG_F(INFO, "TDA7433 subaddress = 0x%X, auto increment = %d",
|
||||||
|
this->sub_addr, this->auto_inc);
|
||||||
|
this->pos++;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool send_byte(uint8_t data) {
|
||||||
|
if (!this->pos) {
|
||||||
|
return send_subaddress(data);
|
||||||
|
} else if (this->sub_addr <= 6) {
|
||||||
|
LOG_F(INFO, "TDA7433 byte 0x%X received", data);
|
||||||
|
this->regs[this->sub_addr] = data;
|
||||||
|
if (this->auto_inc) {
|
||||||
|
this->sub_addr++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false; /* invalid sub_addr -> no acknowledge */
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool receive_byte(uint8_t *p_data) {
|
||||||
|
*p_data = this->regs[this->sub_addr];
|
||||||
|
LOG_F(INFO, "TDA7433 byte 0x%X sent", *p_data);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t regs[7]; /* control registers, see TDA7433 datasheet */
|
||||||
|
uint8_t sub_addr;
|
||||||
|
int pos;
|
||||||
|
int auto_inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AWACDevice {
|
||||||
|
public:
|
||||||
|
AWACDevice();
|
||||||
|
~AWACDevice();
|
||||||
|
|
||||||
|
uint32_t snd_ctrl_read(uint32_t offset, int size);
|
||||||
|
void snd_ctrl_write(uint32_t offset, uint32_t value, int size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t snd_ctrl_reg = {0};
|
||||||
|
uint16_t control_regs[8] = {0}; /* control registers, each 12-bits wide */
|
||||||
|
uint8_t is_busy = 0;
|
||||||
|
AudioProcessor *audio_proc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* AWAC_H */
|
@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "macio.h"
|
#include "macio.h"
|
||||||
#include "viacuda.h"
|
#include "viacuda.h"
|
||||||
|
#include "awacs.h"
|
||||||
#include "machines/machinebase.h"
|
#include "machines/machinebase.h"
|
||||||
|
|
||||||
/** Heathrow Mac I/O device emulation.
|
/** Heathrow Mac I/O device emulation.
|
||||||
@ -35,10 +36,12 @@ using namespace std;
|
|||||||
|
|
||||||
HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow")
|
HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow")
|
||||||
{
|
{
|
||||||
this->viacuda = new ViaCuda();
|
this->nvram = new NVram();
|
||||||
this->nvram = new NVram();
|
|
||||||
|
|
||||||
|
this->viacuda = new ViaCuda();
|
||||||
gMachineObj->add_subdevice("ViaCuda", this->viacuda);
|
gMachineObj->add_subdevice("ViaCuda", this->viacuda);
|
||||||
|
|
||||||
|
this->screamer = new AWACDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
HeathrowIC::~HeathrowIC()
|
HeathrowIC::~HeathrowIC()
|
||||||
@ -93,10 +96,10 @@ uint32_t HeathrowIC::read(uint32_t offset, int size)
|
|||||||
res = mio_ctrl_read(offset, size);
|
res = mio_ctrl_read(offset, size);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
LOG_F(9, "Attempting to read DMA channel register space \n");
|
LOG_F(WARNING, "Attempting to read DMA channel register space \n");
|
||||||
break;
|
break;
|
||||||
case 0x14:
|
case 0x14:
|
||||||
LOG_F(9, "Attempting to read AWACS-Screamer register space \n");
|
res = this->screamer->snd_ctrl_read(offset - 0x14000, size);
|
||||||
break;
|
break;
|
||||||
case 0x16:
|
case 0x16:
|
||||||
case 0x17:
|
case 0x17:
|
||||||
@ -125,10 +128,10 @@ void HeathrowIC::write(uint32_t offset, uint32_t value, int size)
|
|||||||
mio_ctrl_write(offset, value, size);
|
mio_ctrl_write(offset, value, size);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
LOG_F(9, "Attempting to write to DMA channel register space \n");
|
LOG_F(WARNING, "Attempting to write to DMA channel register space \n");
|
||||||
break;
|
break;
|
||||||
case 0x14:
|
case 0x14:
|
||||||
LOG_F(9, "Attempting to write to AWACS-Screamer register space \n");
|
this->screamer->snd_ctrl_write(offset - 0x14000, value, size);
|
||||||
break;
|
break;
|
||||||
case 0x16:
|
case 0x16:
|
||||||
case 0x17:
|
case 0x17:
|
||||||
|
@ -59,6 +59,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include "pcihost.h"
|
#include "pcihost.h"
|
||||||
#include "viacuda.h"
|
#include "viacuda.h"
|
||||||
#include "nvram.h"
|
#include "nvram.h"
|
||||||
|
#include "awacs.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Heathrow ASIC emulation
|
Heathrow ASIC emulation
|
||||||
@ -126,8 +127,9 @@ private:
|
|||||||
uint32_t feat_ctrl; // features control register
|
uint32_t feat_ctrl; // features control register
|
||||||
|
|
||||||
/* device cells */
|
/* device cells */
|
||||||
ViaCuda *viacuda; /* VIA cell with Cuda MCU attached to it */
|
ViaCuda *viacuda; /* VIA cell with Cuda MCU attached to it */
|
||||||
NVram *nvram; /* NVRAM cell */
|
NVram *nvram; /* NVRAM cell */
|
||||||
|
AWACDevice *screamer; /* Screamer audio codec instance */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MACIO_H */
|
#endif /* MACIO_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user