diff --git a/devices/sound/awacs.cpp b/devices/sound/awacs.cpp
index 40740d4..f169d2e 100644
--- a/devices/sound/awacs.cpp
+++ b/devices/sound/awacs.cpp
@@ -26,9 +26,11 @@ along with this program. If not, see .
- Screamer AWACs in Beige G3
*/
+#include
#include
#include
#include
+#include
#include
#include
@@ -97,6 +99,49 @@ void AwacsBase::dma_out_pause() {
this->out_stream_running = false;
}
+static const char sound_input_data[2048] = {0};
+static int sound_in_status = 0x10;
+
+void AwacsBase::dma_in_data()
+{
+ // transfer data from sound input device
+ 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(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,
+ [this]() {
+ // re-enter the sequencer with the state specified in next_state
+ this->dma_in_timer_id = 0;
+ this->dma_in_data();
+ });
+ }
+}
+
+void AwacsBase::dma_in_start() {
+ LOG_F(ERROR, "%s: dma_in_start", this->name.c_str());
+ dma_in_data();
+}
+
+void AwacsBase::dma_in_stop() {
+ if (this->dma_in_timer_id) {
+ TimerManager::get_instance()->cancel_timer(this->dma_in_timer_id);
+ this->dma_in_timer_id = 0;
+ }
+ LOG_F(ERROR, "%s: dma_in_stop", this->name.c_str());
+}
+
+void AwacsBase::dma_in_pause() {
+ LOG_F(ERROR, "%s: dma_in_pause", this->name.c_str());
+}
+
//=========================== PDM-style AWACs =================================
AwacDevicePdm::AwacDevicePdm() : AwacsBase("AWAC-PDM") {
static int pdm_awac_freqs[3] = {22050, 29400, 44100};
diff --git a/devices/sound/awacs.h b/devices/sound/awacs.h
index 19aa9e4..088a503 100644
--- a/devices/sound/awacs.h
+++ b/devices/sound/awacs.h
@@ -36,6 +36,7 @@ along with this program. If not, see .
#include
class DmaOutChannel;
+class DmaInChannel;
class SoundServer;
/** Base class for the AWACs codecs. */
@@ -48,14 +49,24 @@ public:
this->dma_out_ch = dma_out_ch;
};
+ void set_dma_in(DmaInChannel *dma_in_ch) {
+ this->dma_in_ch = dma_in_ch;
+ };
+
void set_sample_rate(int sr_id);
void dma_out_start();
void dma_out_stop();
void dma_out_pause();
+ void dma_in_start();
+ void dma_in_stop();
+ void dma_in_pause();
+ void dma_in_data();
protected:
SoundServer *snd_server; // SoundServer instance pointer
DmaOutChannel *dma_out_ch; // DMA output channel instance pointer
+ DmaInChannel *dma_in_ch; // DMA input channel instance pointer
+ uint32_t dma_in_timer_id = 0;
int *sr_table; // pointer to the table of supported sample rates
int max_sr_id; // maximum value for sample rate ID