mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-12-01 06:23:18 -10:00
Compare commits
13
Commits
mmu
...
awacs-pdm-fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
117b8dccfc | ||
|
|
2b4b0e8320 | ||
|
|
90d050531e | ||
|
|
b5ddcf8ece | ||
|
|
e97da11386 | ||
|
|
10be145179 | ||
|
|
0236493902 | ||
|
|
b87585cf0e | ||
|
|
a69bffaad4 | ||
|
|
38ba5cbfa8 | ||
|
|
74b851d4e0 | ||
|
|
b3a38cdac3 | ||
|
|
70da33b2af |
No files matched your search
@@ -488,7 +488,7 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
|
||||
if (this->ch_stat & CH_STAT_DEAD || !(this->ch_stat & CH_STAT_ACTIVE)) {
|
||||
// dead or idle channel? -> no more data
|
||||
LOG_F(WARNING, "%s: Dead/idle channel -> no more data", this->get_name().c_str());
|
||||
return DmaPullResult::NoMoreData;
|
||||
return DmaPullResult::NoMorePullData;
|
||||
}
|
||||
|
||||
// interpret DBDMA program until we get data or become idle
|
||||
@@ -513,10 +513,10 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
|
||||
this->res_count += this->queue_len;
|
||||
this->queue_len = 0;
|
||||
}
|
||||
return DmaPullResult::MoreData; // tell the caller there is more data
|
||||
return DmaPullResult::MorePullData; // tell the caller there is more data
|
||||
}
|
||||
|
||||
return DmaPullResult::NoMoreData; // tell the caller there is no more data
|
||||
return DmaPullResult::NoMorePullData; // tell the caller there is no more data
|
||||
}
|
||||
|
||||
int DMAChannel::push_data(const char* src_ptr, int len) {
|
||||
|
||||
@@ -29,8 +29,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <string>
|
||||
|
||||
enum DmaPullResult : int {
|
||||
MoreData, // data source has more data to be pulled
|
||||
NoMoreData, // data source has no more data to be pulled
|
||||
MorePullData, // data source has more data to be pulled
|
||||
NoMorePullData, // data source has no more data to be pulled
|
||||
};
|
||||
|
||||
enum DmaPushResult : int {
|
||||
MorePushData, // data source has more data to be pushed
|
||||
NoMorePushData, // data source has no more data to be pushed
|
||||
};
|
||||
|
||||
class DmaOutChannel {
|
||||
|
||||
+121
-23
@@ -78,8 +78,11 @@ AMIC::AMIC() : MMIODevice()
|
||||
// initialize sound HW
|
||||
this->snd_out_dma = std::unique_ptr<AmicSndOutDma>(new AmicSndOutDma());
|
||||
this->snd_out_dma->init_interrupts(this, DMA1_INT_SOUND << DMA1_INT_SHIFT);
|
||||
this->snd_in_dma = std::unique_ptr<AmicSndInDma>(new AmicSndInDma());
|
||||
this->snd_in_dma->init_interrupts(this, DMA0_INT_SOUND << DMA0_INT_SHIFT);
|
||||
this->awacs = std::unique_ptr<AwacDevicePdm> (new AwacDevicePdm());
|
||||
this->awacs->set_dma_out(this->snd_out_dma.get());
|
||||
this->awacs->set_dma_in(this->snd_in_dma.get());
|
||||
|
||||
// initialize on-board video
|
||||
this->disp_id = std::unique_ptr<DisplayID> (new DisplayID());
|
||||
@@ -150,6 +153,10 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
}
|
||||
case 0x14: // Sound registers
|
||||
switch (offset) {
|
||||
case AMICReg::Snd_Ctrl_0:
|
||||
case AMICReg::Snd_Ctrl_1:
|
||||
case AMICReg::Snd_Ctrl_2:
|
||||
return this->imm_snd_regs[offset & 3];
|
||||
case AMICReg::Snd_Stat_0:
|
||||
case AMICReg::Snd_Stat_1:
|
||||
case AMICReg::Snd_Stat_2:
|
||||
@@ -167,8 +174,12 @@ uint32_t AMIC::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
}
|
||||
case AMICReg::Snd_Out_Ctrl:
|
||||
return this->snd_out_ctrl;
|
||||
case AMICReg::Snd_In_Ctrl:
|
||||
return this->snd_in_ctrl;
|
||||
case AMICReg::Snd_Out_DMA:
|
||||
return this->snd_out_dma->read_stat();
|
||||
case AMICReg::Snd_In_DMA:
|
||||
return this->snd_in_dma->read_stat();
|
||||
}
|
||||
break;
|
||||
case 0x16: // SWIM3 registers
|
||||
@@ -250,19 +261,19 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
|
||||
uint32_t mask;
|
||||
|
||||
// subdevices registers
|
||||
switch(offset >> 12) {
|
||||
case 0: // VIA1 registers
|
||||
switch (offset >> 12) {
|
||||
case 0: // VIA1 registers
|
||||
case 1:
|
||||
this->viacuda->write(offset >> 9, value);
|
||||
return;
|
||||
case 4: // SCC registers
|
||||
case 4: // SCC registers
|
||||
if ((offset & 0xF) < 0x0C)
|
||||
this->escc->write(compat_to_macrisc[(offset >> 1) & 0xF], value);
|
||||
else
|
||||
LOG_F(ERROR, "AMIC SCC write @%x.%c = %0*x",
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
return;
|
||||
case 0xA: // MACE registers
|
||||
case 0xA: // MACE registers
|
||||
this->mace->write((offset >> 4) & 0x1F, value);
|
||||
return;
|
||||
case 0x10:
|
||||
@@ -271,8 +282,8 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
|
||||
else
|
||||
this->scsi->write((offset >> 4) & 0xF, value);
|
||||
return;
|
||||
case 0x14: // Sound registers
|
||||
switch(offset) {
|
||||
case 0x14: // Sound registers
|
||||
switch (offset) {
|
||||
case AMICReg::Snd_Ctrl_0:
|
||||
case AMICReg::Snd_Ctrl_1:
|
||||
case AMICReg::Snd_Ctrl_2:
|
||||
@@ -282,42 +293,66 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
|
||||
if ((this->imm_snd_regs[0] & 0xC0) == PDM_SND_CTRL_VALID) {
|
||||
this->awacs->write_ctrl(
|
||||
(this->imm_snd_regs[1] >> 4) | (this->imm_snd_regs[0] & 0x3F),
|
||||
((this->imm_snd_regs[1] & 0xF) << 8) | this->imm_snd_regs[2]
|
||||
);
|
||||
((this->imm_snd_regs[1] & 0xF) << 8) | this->imm_snd_regs[2]);
|
||||
}
|
||||
return;
|
||||
case AMICReg::Snd_Buf_Size_Hi:
|
||||
case AMICReg::Snd_Buf_Size_Lo:
|
||||
SET_SIZE_BYTE(this->snd_buf_size, offset, value);
|
||||
this->snd_buf_size &= ~3; // sound buffer size is always a multiple of 4
|
||||
this->snd_buf_size &= ~3; // sound buffer size is always a multiple of 4
|
||||
LOG_F(9, "AMIC: Sound buffer size set to 0x%X", this->snd_buf_size);
|
||||
return;
|
||||
case AMICReg::Snd_Out_Ctrl:
|
||||
if ((value & 1) != (this->snd_out_ctrl & 1)) {
|
||||
if (value & 1) {
|
||||
this->snd_out_dma->init(this->dma_base & ~0x3FFFF,
|
||||
this->snd_buf_size);
|
||||
this->snd_out_dma->init(this->dma_base & ~0x3FFFF, this->snd_buf_size);
|
||||
this->snd_out_dma->enable();
|
||||
this->awacs->set_sample_rate((this->snd_out_ctrl >> 1) & 3);
|
||||
this->awacs->dma_out_start();
|
||||
this->snd_out_ctrl |= 1;
|
||||
} else {
|
||||
this->snd_out_dma->disable();
|
||||
this->awacs->dma_out_pause();
|
||||
this->snd_out_ctrl &= 0xFE;
|
||||
}
|
||||
}
|
||||
this->snd_out_ctrl = value;
|
||||
return;
|
||||
case AMICReg::Snd_In_Ctrl:
|
||||
LOG_F(INFO, "AMIC Sound In Ctrl updated, val=%x", value);
|
||||
if ((value & 1) != (this->snd_in_ctrl & 1)) {
|
||||
if (value & 1) {
|
||||
this->snd_in_dma->init(this->dma_base & ~0x3FFFF, this->snd_buf_size);
|
||||
this->snd_in_dma->enable();
|
||||
this->awacs->set_sample_rate((this->snd_out_ctrl >> 1) & 3);
|
||||
this->awacs->dma_in_start();
|
||||
}
|
||||
} else {
|
||||
this->snd_in_dma->disable();
|
||||
this->awacs->dma_in_pause();
|
||||
}
|
||||
|
||||
if (value & 0x40) {
|
||||
this->via2_ifr |= 0x10;
|
||||
this->ack_via2_int(VIA2_INT_SOUND, 0);
|
||||
} else {
|
||||
this->via2_ifr |= 0x10;
|
||||
this->ack_via2_int(VIA2_INT_SOUND, 1);
|
||||
}
|
||||
this->snd_in_ctrl = value;
|
||||
return;
|
||||
case AMICReg::Snd_Out_DMA:
|
||||
this->snd_out_dma->write_dma_out_ctrl(value);
|
||||
return;
|
||||
case AMICReg::Snd_In_DMA:
|
||||
LOG_F(WARNING, "SND IN DMA Value: 0x%x", value);
|
||||
this->snd_in_dma->write_dma_in_ctrl(value);
|
||||
return;
|
||||
}
|
||||
case 0x16: // SWIM3 registers
|
||||
case 0x17:
|
||||
case 0x16: // SWIM3 registers
|
||||
case 0x17: {
|
||||
this->swim3->write((offset >> 9) & 0xF, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(offset) {
|
||||
@@ -328,6 +363,7 @@ void AMIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size)
|
||||
}
|
||||
break;
|
||||
case AMICReg::VIA2_IFR:
|
||||
case AMICReg::VIA2_IFR_RBV:
|
||||
// if bit 7 is set, clear the corresponding IRQ bit for each "1" in value
|
||||
// writing any value to VIA2_IFR with bit 7 cleared has no effect
|
||||
if (value & 0x80) {
|
||||
@@ -598,10 +634,9 @@ AmicSndOutDma::AmicSndOutDma() : DmaOutChannel("SndOut")
|
||||
this->enabled = false;
|
||||
}
|
||||
|
||||
void AmicSndOutDma::init(uint32_t buf_base, uint32_t buf_samples)
|
||||
{
|
||||
this->out_buf0 = buf_base + AMIC_SND_BUF0_OFFS;
|
||||
this->out_buf1 = buf_base + AMIC_SND_BUF1_OFFS;
|
||||
void AmicSndOutDma::init(uint32_t buf_base, uint32_t buf_samples) {
|
||||
this->out_buf0 = buf_base + AMIC_SND_OUT_BUF0_OFFS;
|
||||
this->out_buf1 = buf_base + AMIC_SND_OUT_BUF1_OFFS;
|
||||
|
||||
this->out_buf_len = buf_samples * 2 * 2;
|
||||
|
||||
@@ -659,7 +694,7 @@ DmaPullResult AmicSndOutDma::pull_data(uint32_t req_len, uint32_t *avail_len,
|
||||
// if it's false stop delivering sound data
|
||||
// this will effectively stop audio playback
|
||||
if (this->snd_buf_num && !this->enabled) {
|
||||
return DmaPullResult::NoMoreData;
|
||||
return DmaPullResult::NoMorePullData;
|
||||
}
|
||||
|
||||
this->cur_buf_pos = 0; // reset buffer position
|
||||
@@ -675,7 +710,70 @@ DmaPullResult AmicSndOutDma::pull_data(uint32_t req_len, uint32_t *avail_len,
|
||||
*p_data = res.host_va;
|
||||
this->cur_buf_pos += len;
|
||||
*avail_len = len;
|
||||
return DmaPullResult::MoreData;
|
||||
return DmaPullResult::MorePullData;
|
||||
}
|
||||
|
||||
|
||||
AmicSndInDma::AmicSndInDma() : DmaInChannel("SndIn") {
|
||||
this->dma_in_ctrl = 0;
|
||||
this->enabled = false;
|
||||
}
|
||||
|
||||
void AmicSndInDma::init(uint32_t buf_base, uint32_t buf_samples) {
|
||||
this->in_buf0 = buf_base + AMIC_SND_IN_BUF0_OFFS;
|
||||
this->in_buf1 = buf_base + AMIC_SND_IN_BUF1_OFFS;
|
||||
|
||||
this->in_buf_len = buf_samples * 2 * 2;
|
||||
|
||||
this->snd_buf_num = 0;
|
||||
this->cur_buf_pos = 0;
|
||||
this->irq_level = 0;
|
||||
}
|
||||
|
||||
uint8_t AmicSndInDma::read_stat() {
|
||||
return this->dma_in_ctrl;
|
||||
}
|
||||
|
||||
void AmicSndInDma::write_dma_in_ctrl(uint8_t value) {
|
||||
if (value & PDM_DMA_INTS_MASK) {
|
||||
this->dma_in_ctrl &= ~(value & PDM_DMA_INTS_MASK);
|
||||
this->update_irq();
|
||||
}
|
||||
// update sound input DMA interrupt enable bits
|
||||
this->dma_in_ctrl = value;
|
||||
}
|
||||
|
||||
int AmicSndInDma::push_data(const char* src_ptr, int len) {
|
||||
len = 0x2000;
|
||||
const char* silence[0x2000] = {(char *)0};
|
||||
|
||||
MapDmaResult res = mmu_map_dma_mem(
|
||||
(this->snd_buf_num ? this->in_buf1 : this->in_buf0),
|
||||
len, false);
|
||||
uint8_t* p_data = res.host_va;
|
||||
if (!res.is_writable) {
|
||||
ABORT_F("AMIC: attempting DMA write to read-only memory");
|
||||
}
|
||||
std::memcpy(p_data, silence, len);
|
||||
|
||||
this->addr_ptr += len;
|
||||
this->byte_count -= len;
|
||||
if (!this->byte_count) {
|
||||
//LOG_F(WARNING, "AMIC: DMA interrupts not implemented yet");
|
||||
}
|
||||
|
||||
this->snd_buf_num ^= 1;
|
||||
|
||||
return DmaPushResult::NoMorePushData;
|
||||
}
|
||||
|
||||
void AmicSndInDma::update_irq() {
|
||||
uint8_t new_level = !!((this->dma_in_ctrl >> 4) & this->dma_in_ctrl);
|
||||
if (new_level != this->irq_level) {
|
||||
this->irq_level = new_level;
|
||||
TimerManager::get_instance()->add_immediate_timer(
|
||||
[this] { this->int_ctrl->ack_dma_int(this->snd_dma_irq_id, this->irq_level); });
|
||||
}
|
||||
}
|
||||
|
||||
// ============================ Floppy DMA stuff ===============================
|
||||
@@ -726,7 +824,7 @@ int AmicFloppyDma::push_data(const char* src_ptr, int len)
|
||||
DmaPullResult AmicFloppyDma::pull_data(uint32_t req_len, uint32_t *avail_len,
|
||||
uint8_t **p_data)
|
||||
{
|
||||
return DmaPullResult::NoMoreData;
|
||||
return DmaPullResult::NoMorePullData;
|
||||
}
|
||||
|
||||
// ============================ SCSI DMA stuff ================================
|
||||
@@ -822,7 +920,7 @@ void AmicSerialXmitDma::write_ctrl(const uint8_t value)
|
||||
DmaPullResult AmicSerialXmitDma::pull_data(uint32_t req_len, uint32_t *avail_len,
|
||||
uint8_t **p_data)
|
||||
{
|
||||
return DmaPullResult::NoMoreData;
|
||||
return DmaPullResult::NoMorePullData;
|
||||
}
|
||||
|
||||
static std::vector<std::string> Amic_Subdevices = {
|
||||
@@ -833,4 +931,4 @@ static const DeviceDescription Amic_Descriptor = {
|
||||
AMIC::create, Amic_Subdevices, {}, HWCompType::MMIO_DEV | HWCompType::INT_CTRL
|
||||
};
|
||||
|
||||
REGISTER_DEVICE(Amic, Amic_Descriptor);
|
||||
REGISTER_DEVICE(Amic, Amic_Descriptor);
|
||||
+59
-8
@@ -82,13 +82,16 @@ enum : uint64_t {
|
||||
/** DMA interrupt bits. */
|
||||
enum : uint64_t {
|
||||
DMA0_INT_SHIFT = 24,
|
||||
DMA0_INT_SOUND = 1 << 1,
|
||||
DMA1_INT_SHIFT = 32,
|
||||
DMA1_INT_SOUND = 1 << 1,
|
||||
};
|
||||
|
||||
/** AMIC sound buffers are located at fixed offsets from DMA base. */
|
||||
#define AMIC_SND_BUF0_OFFS 0x10000
|
||||
#define AMIC_SND_BUF1_OFFS 0x12000
|
||||
#define AMIC_SND_IN_BUF0_OFFS 0xC000
|
||||
#define AMIC_SND_IN_BUF1_OFFS 0xE000
|
||||
#define AMIC_SND_OUT_BUF0_OFFS 0x10000
|
||||
#define AMIC_SND_OUT_BUF1_OFFS 0x12000
|
||||
|
||||
// PDM HWInit source defines two constants: kExpBit = 0x80 and kCmdBit = 0x40
|
||||
// I don't know what they mean but it seems that their combination will
|
||||
@@ -135,6 +138,48 @@ private:
|
||||
uint8_t irq_level = 0;
|
||||
};
|
||||
|
||||
class AmicSndInDma : public DmaInChannel {
|
||||
public:
|
||||
AmicSndInDma();
|
||||
~AmicSndInDma() = default;
|
||||
|
||||
void init(uint32_t buf_base, uint32_t buf_samples);
|
||||
void enable() {
|
||||
this->enabled = true;
|
||||
}
|
||||
void disable() {
|
||||
this->enabled = false;
|
||||
}
|
||||
uint8_t read_stat();
|
||||
void update_irq();
|
||||
void write_dma_in_ctrl(uint8_t value);
|
||||
uint32_t get_cur_buf_pos() {
|
||||
return this->cur_buf_pos;
|
||||
}
|
||||
int push_data(const char* src_ptr, int len);
|
||||
|
||||
void init_interrupts(InterruptCtrl* int_ctrl, uint64_t irq_id) {
|
||||
this->int_ctrl = int_ctrl;
|
||||
this->snd_dma_irq_id = irq_id;
|
||||
}
|
||||
|
||||
private:
|
||||
bool enabled = false;
|
||||
uint8_t dma_in_ctrl;
|
||||
|
||||
uint32_t in_buf0;
|
||||
uint32_t in_buf1;
|
||||
uint32_t in_buf_len;
|
||||
uint32_t snd_buf_num;
|
||||
uint32_t cur_buf_pos;
|
||||
|
||||
InterruptCtrl* int_ctrl = nullptr;
|
||||
uint64_t snd_dma_irq_id = 0;
|
||||
uint32_t addr_ptr;
|
||||
uint16_t byte_count;
|
||||
uint8_t irq_level = 0;
|
||||
};
|
||||
|
||||
/** AMIC-specific floppy DMA implementation. */
|
||||
class AmicFloppyDma : public DmaBidirChannel {
|
||||
public:
|
||||
@@ -282,16 +327,20 @@ enum AMICReg : uint32_t {
|
||||
Floppy_DMA_Ctrl = 0x32068,
|
||||
|
||||
SCC_DMA_Xmt_A_Ctrl = 0x32088,
|
||||
// = 0x32092, // byte, read
|
||||
// = 0x32093, // byte, read
|
||||
SCC_RXA_Addr_Ptr_0 = 0x32090, // byte, read
|
||||
SCC_RXA_Addr_Ptr_1 = 0x32091, // byte, read
|
||||
SCC_RXA_Addr_Ptr_2 = 0x32092, // byte, read
|
||||
SCC_RXA_Addr_Ptr_3 = 0x32093, // byte, read
|
||||
SCC_RXA_Byte_Cnt_Hi = 0x32094, // 5 bits, read; byte, write 0x10
|
||||
SCC_RXA_Byte_Cnt_Lo = 0x32095, // 8 bits, read; byte, write 0x00
|
||||
SCC_DMA_Rcv_A_Ctrl = 0x32098,
|
||||
// = 0x320A4, // byte, write 0x00
|
||||
// = 0x320A5, // byte, write 0x07
|
||||
SCC_TXB_Byte_Cnt_Hi = 0x320A4, // byte, write 0x00
|
||||
SCC_TXB_Byte_Cnt_Lo = 0x320A5, // byte, write 0x07
|
||||
SCC_DMA_Xmt_B_Ctrl = 0x320A8,
|
||||
// = 0x320B2, // byte, read
|
||||
// = 0x320B3, // byte, read
|
||||
SCC_RXB_Addr_Ptr_0 = 0x320B0, // byte, read
|
||||
SCC_RXB_Addr_Ptr_1 = 0x320B1, // byte, read
|
||||
SCC_RXB_Addr_Ptr_2 = 0x320B2, // byte, read
|
||||
SCC_RXB_Addr_Ptr_3 = 0x320B3, // byte, read
|
||||
SCC_RXB_Byte_Cnt_Hi = 0x320B4, // 5 bits, read; byte, write 0x10
|
||||
SCC_RXB_Byte_Cnt_Lo = 0x320B5, // 8 bits, read; byte, write 0x00
|
||||
SCC_DMA_Rcv_B_Ctrl = 0x320B8,
|
||||
@@ -335,6 +384,7 @@ private:
|
||||
uint32_t scsi_dma_base = 0; // physical base address for SCSI DMA
|
||||
uint16_t snd_buf_size = 0; // sound buffer size in bytes
|
||||
uint8_t snd_out_ctrl = 0;
|
||||
uint8_t snd_in_ctrl = 0;
|
||||
|
||||
// floppy DMA state
|
||||
uint32_t floppy_addr_ptr;
|
||||
@@ -373,6 +423,7 @@ private:
|
||||
|
||||
std::unique_ptr<AwacDevicePdm> awacs;
|
||||
std::unique_ptr<AmicSndOutDma> snd_out_dma;
|
||||
std::unique_ptr<AmicSndInDma> snd_in_dma;
|
||||
std::unique_ptr<AmicFloppyDma> floppy_dma;
|
||||
std::unique_ptr<AmicScsiDma> curio_dma;
|
||||
std::unique_ptr<AmicSerialXmitDma> escc_xmit_b_dma;
|
||||
|
||||
@@ -442,7 +442,7 @@ void EsccChannel::dma_out_tx()
|
||||
uint8_t *data;
|
||||
uint32_t avail_len;
|
||||
|
||||
if (dma_ch[1]->pull_data(256, &avail_len, &data) == MoreData) {
|
||||
if (dma_ch[1]->pull_data(256, &avail_len, &data) == MorePullData) {
|
||||
while(avail_len) {
|
||||
this->send_byte(*data++);
|
||||
avail_len--;
|
||||
|
||||
+16
-10
@@ -99,7 +99,7 @@ void AwacsBase::dma_out_pause() {
|
||||
this->out_stream_running = false;
|
||||
}
|
||||
|
||||
static const char sound_input_data[2048] = {0};
|
||||
static const char sound_input_data[8192] = {0};
|
||||
static int sound_in_status = 0x10;
|
||||
|
||||
void AwacsBase::dma_in_data() {
|
||||
@@ -107,15 +107,15 @@ void AwacsBase::dma_in_data() {
|
||||
this->dma_in_ch->push_data(sound_input_data, sizeof(sound_input_data));
|
||||
|
||||
if (dma_in_ch->is_in_active()) {
|
||||
auto dbdma_ch = dynamic_cast<DMAChannel*>(dma_in_ch);
|
||||
sound_in_status <<= 1;
|
||||
if (!sound_in_status)
|
||||
sound_in_status = 1;
|
||||
dbdma_ch->set_stat(sound_in_status);
|
||||
LOG_F(INFO, "%s: status:%x", this->name.c_str(), sound_in_status);
|
||||
//auto dbdma_ch = dynamic_cast<DMAChannel*>(dma_in_ch);
|
||||
//sound_in_status <<= 1;
|
||||
//if (!sound_in_status)
|
||||
// sound_in_status = 1;
|
||||
//dbdma_ch->set_stat(sound_in_status);
|
||||
//LOG_F(INFO, "%s: status:%x", this->name.c_str(), sound_in_status);
|
||||
|
||||
this->dma_in_timer_id = TimerManager::get_instance()->add_oneshot_timer(
|
||||
10000,
|
||||
20000,
|
||||
[this]() {
|
||||
// re-enter the sequencer with the state specified in next_state
|
||||
this->dma_in_timer_id = 0;
|
||||
@@ -135,10 +135,16 @@ void AwacsBase::dma_in_stop() {
|
||||
this->dma_in_timer_id = 0;
|
||||
}
|
||||
LOG_F(ERROR, "%s: dma_in_stop", this->name.c_str());
|
||||
if (this->out_stream_ready) {
|
||||
snd_server->close_out_stream();
|
||||
this->out_stream_ready = false;
|
||||
this->out_stream_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AwacsBase::dma_in_pause() {
|
||||
LOG_F(ERROR, "%s: dma_in_pause", this->name.c_str());
|
||||
this->in_stream_running = false;
|
||||
}
|
||||
|
||||
//=========================== PDM-style AWACs =================================
|
||||
@@ -192,7 +198,7 @@ uint32_t AwacsScreamer::snd_ctrl_read(uint32_t offset, int size) {
|
||||
value = this->snd_ctrl_reg;
|
||||
break;
|
||||
case AWAC_CODEC_CTRL_REG:
|
||||
value = this->is_busy;
|
||||
value = this->is_busy ? AWAC_BUSY_BIT : 0;
|
||||
break;
|
||||
case AWAC_CODEC_STATUS_REG:
|
||||
value = (AWAC_AVAILABLE << 8) | (AWAC_MAKER_CRYSTAL << 16) |
|
||||
@@ -232,7 +238,7 @@ void AwacsScreamer::snd_ctrl_write(uint32_t offset, uint32_t value, int size) {
|
||||
LOG_F(9, "%s subframe = %d, reg = %d, data = %08X", this->name.c_str(),
|
||||
subframe, reg_num, data);
|
||||
if (!subframe)
|
||||
this->shadow_regs[reg_num] = data;
|
||||
this->codec_ctrl_reg = data;
|
||||
break;
|
||||
case AWAC_CLIP_COUNT:
|
||||
this->clip_count = BYTESWAP_32(value);
|
||||
|
||||
@@ -73,8 +73,11 @@ protected:
|
||||
|
||||
bool out_stream_ready = false;
|
||||
bool out_stream_running = false;
|
||||
bool in_stream_ready = false;
|
||||
bool in_stream_running = false;
|
||||
int cur_sample_rate = -1;
|
||||
int out_sample_rate = -1;
|
||||
int in_sample_rate = -1;
|
||||
};
|
||||
|
||||
/** AWACs PDM-style sound codec. */
|
||||
|
||||
@@ -69,6 +69,10 @@ void BurgundyCodec::snd_ctrl_write(uint32_t offset, uint32_t value, int size) {
|
||||
value = BYTESWAP_32(value);
|
||||
|
||||
switch (offset) {
|
||||
case AWAC_SOUND_CTRL_REG:
|
||||
this->snd_ctrl_reg = BYTESWAP_32(value);
|
||||
this->set_sample_rate((this->snd_ctrl_reg >> 8) & 7);
|
||||
break;
|
||||
case AWAC_CODEC_CTRL_REG:
|
||||
this->last_ctrl_data = value;
|
||||
reg_addr = (value >> 12) & 0xFF;
|
||||
|
||||
@@ -58,6 +58,8 @@ private:
|
||||
uint8_t read_pos = 0;
|
||||
uint8_t data_byte = 0;
|
||||
|
||||
uint32_t snd_ctrl_reg = 0;
|
||||
|
||||
uint32_t reg_array[BURGUNDY_NUM_REGS] = {};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user