Skip to content

Commit

Permalink
Merge remote-tracking branch 'henrix/dev-kernel-4.4.y-xenomai-3-suppo…
Browse files Browse the repository at this point in the history
…rt' into dev

still using OUR pru_rtaudio.p.
  • Loading branch information
giuliomoro committed Dec 20, 2017
2 parents 8d0196c + d323c5e commit a98e51c
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 93 deletions.
15 changes: 7 additions & 8 deletions core/PRU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/

#include "../include/PRU.h"
#include "../include/PruBinary.h"
#include "../include/prussdrv.h"
#include "../include/pruss_intc_mapping.h"
#include "../include/digital_gpio_mapping.h"
#include "../include/GPIOcontrol.h"
#include "../include/Bela.h"
#include "../include/pru_rtaudio_bin.h"
#include "../include/Gpio.h"
#include "../include/Utilities.h"

Expand All @@ -41,7 +41,6 @@

#if (defined(CTAGE_FACE_8CH) || defined(CTAG_FACE_16CH))
#define PRU_USES_MCASP_IRQ
#error TODO: load different PRU code
#endif

#if !(defined(BELA_USE_POLL) || defined(BELA_USE_RTDM))
Expand Down Expand Up @@ -711,6 +710,12 @@ int PRU::start(char * const filename)
pru_buffer_comm = pruMemory->getPruBufferComm();
initialisePruCommon();

#ifdef PRU_USES_MCASP_IRQ
const unsigned int* PRUcode = IrqPruCode::getBinary();
#else /* PRU_USES_MCASP_IRQ */
const unsigned int* PRUcode = NonIrqPruCode::getBinary();
#endif /* PRU_USES_MCASP_IRQ */

/* Load and execute binary on PRU */
if(filename[0] == '\0') { //if the string is empty, load the embedded code
if(gRTAudioVerbose)
Expand Down Expand Up @@ -841,13 +846,7 @@ void PRU::loop(void *userData, void(*render)(BelaContext*, void*), bool highPerf
int16_to_float_audio(2 * context->audioFrames, audio_adc_pru_buffer, context->audioIn);
// TODO: implement non-interlaved
#else

#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
//TODO: @henrix: what is this about?
int audioInChannels = context->audioInChannels > 8 ? 8 : context->audioInChannels;
#else
int audioInChannels = context->audioInChannels;
#endif /* defined CTAG */
if(interleaved)
{
for(unsigned int n = 0; n < audioInChannels * context->audioFrames; n++) {
Expand Down
34 changes: 8 additions & 26 deletions core/RTAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ int gXenomaiInited = 0;
static const char gRTAudioThreadName[] = "bela-audio";

PRU *gPRU = 0;
#ifdef CTAG_FACE_8CH
Spi_Codec *gAudioCodec = 0;
I2c_Codec *gNotUsedCodec = 0;
#elif defined(CTAG_BEAST_16CH)
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
Spi_Codec *gAudioCodec = 0;
I2c_Codec *gNotUsedCodec = 0;
#else
Expand Down Expand Up @@ -235,9 +232,7 @@ int Bela_initAudio(BelaInitSettings *settings, void *userData)
}

// Initialise the rendering environment: sample rates, frame counts, numbers of channels
#ifdef CTAG_FACE_8CH
gContext.audioSampleRate = 48000.0;
#elif defined(CTAG_BEAST_16CH)
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
gContext.audioSampleRate = 48000.0;
#else
gContext.audioSampleRate = 44100.0;
Expand Down Expand Up @@ -316,14 +311,10 @@ int Bela_initAudio(BelaInitSettings *settings, void *userData)

// Use PRU for audio
gPRU = new PRU(&gContext);
#ifdef CTAG_FACE_8CH
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
gNotUsedCodec = new I2c_Codec();
gNotUsedCodec->disable(); // Put not used codec in high impedance state
gAudioCodec = new Spi_Codec();
#elif defined(CTAG_BEAST_16CH)
gNotUsedCodec = new I2c_Codec();
gNotUsedCodec->disable();
gAudioCodec = new Spi_Codec();
#else
gAudioCodec = new I2c_Codec();
#endif
Expand All @@ -348,10 +339,7 @@ int Bela_initAudio(BelaInitSettings *settings, void *userData)
return 1;
}

#ifdef CTAG_FACE_8CH
gAudioCodec->initCodec();
//gAudioCodec->dumpRegisters();
#elif defined(CTAG_BEAST_16CH)
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
gAudioCodec->initCodec();
//gAudioCodec->dumpRegisters();
#else
Expand Down Expand Up @@ -591,8 +579,7 @@ int Bela_setADCLevel(float decibels)
{

// AD1938 audio codec has no ADC volume controls
#ifdef CTAG_FACE_8CH
#elif defined(CTAG_BEAST_16CH)
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
#else
if(gAudioCodec == 0)
return -1;
Expand All @@ -606,8 +593,7 @@ int Bela_setADCLevel(float decibels)
// 59.5dB is maximum, 0dB is minimum; 0.5dB steps
int Bela_setPgaGain(float decibels, int channel){
//Nothing to be done for CTAG audio cards
#ifdef CTAG_FACE_8CH
#elif defined(CTAG_BEAST_16CH)
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
#else
if(gAudioCodec == 0)
return -1;
Expand All @@ -623,8 +609,7 @@ int Bela_setPgaGain(float decibels, int channel){
int Bela_setHeadphoneLevel(float decibels)
{
//Nothing to be done for CTAG audio cards
#ifdef CTAG_FACE_8CH
#elif defined(CTAG_BEAST_16CH)
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
#else
if(gAudioCodec == 0)
return -1;
Expand All @@ -639,10 +624,7 @@ int Bela_setHeadphoneLevel(float decibels)
int Bela_muteSpeakers(int mute)
{
//Nothing to be done for CTAG audio cards
#ifdef CTAG_FACE_8CH
return 0;
#elif defined(CTAG_BEAST_16CH)
//TODO: Implement for both AD1938 codecs
#if defined(CTAG_FACE_8CH) || defined(CTAG_BEAST_16CH)
return 0;
#else
int pinValue = mute ? LOW : HIGH;
Expand Down
Loading

0 comments on commit a98e51c

Please sign in to comment.