Issue is in the mr_alsa_audio_pcm_playback_copy_internal() function of audio_driver.c that transfers the PCM samples from the ALSA buffer to the Ravenna buffer using the get_user() function. In case of memory access mode the ALSA buffer can be directly accessed by the kernel and the samples must be copied. mr_alsa_audio_pcm_playback_copy_internal() has been modified to handle the transfer of the ALSA buffer from user space (used with read/write access mode) and from kernel space (used by memory access mode). The issue is common to all the platform but impacting ARM only. Additional changes: - changed type for dma_playback_offset and dma_capture_offset variables to uint32_t instead of atomic_t since the pointer callback mr_alsa_audio_pcm_pointer() is now atomic - added variables to the mr_alsa_audio_chip scructure to decrease the number of calls to snd_pcm_lib_xxx() functions. These get assigned in the prepare callback mr_alsa_audio_pcm_prepare() - changed mr_alsa_audio_get_playback_buffer_size_in_frames() to return configured size of Ravenna playback buffer (same as mr_alsa_audio_get_capture_buffer_size_in_frames()) - some rework of the existing patches This fixes issue #20
302 lines
18 KiB
Diff
302 lines
18 KiB
Diff
diff --git a/driver/RTP_audio_stream.c b/driver/RTP_audio_stream.c
|
|
index 5a160e4..a5c84e4 100644
|
|
--- a/driver/RTP_audio_stream.c
|
|
+++ b/driver/RTP_audio_stream.c
|
|
@@ -40,6 +40,7 @@
|
|
|
|
#include "RTP_audio_stream.h"
|
|
#include "MTAL_DP.h"
|
|
+#include "c_wrapper_lib.h"
|
|
|
|
#define DEBUG_TRACE(x) MTAL_DP("[RTP Stream] "); MTAL_DP x
|
|
#define ASSERT(x) {if(!(x)) { MTAL_DP("Assert in %s line %i\n", __FILE__, __LINE__); }}
|
|
@@ -377,7 +378,7 @@ int Create(TRTP_audio_stream* self, TRTP_stream_info* pRTP_stream_info, rtp_audi
|
|
// if audio data format was changed we have to mute channels with the proper mute pattern; for now, we always mute
|
|
for(us = 0; us < pRTP_stream_info->m_byNbOfChannels; us++)
|
|
{
|
|
- //MTAL_DP("[%u] m_pvLivesInCircularBuffer[us] = 0x%x buffer length = %u wordlength = %u\n", us, m_pvLivesInCircularBuffer[us], pManager->get_live_in_jitter_buffer_length(pManager->user), m_usAudioEngineSampleWordLength);
|
|
+ //MTAL_DP("[%u] m_pvLivesInCircularBuffer[us] = 0x%x buffer length = %u wordlength = %u\n", us, self->m_pvLivesInCircularBuffer[us], pManager->get_live_in_jitter_buffer_length(pManager->user), self->m_usAudioEngineSampleWordLength);
|
|
|
|
if(self->m_pvLivesInCircularBuffer[us])
|
|
{ // mute
|
|
@@ -413,7 +414,7 @@ int Destroy(TRTP_audio_stream* self)
|
|
unsigned short us;
|
|
for(us = 0; us < pRTP_stream_info->m_byNbOfChannels; us++)
|
|
{
|
|
- //MTAL_DP("[%u] m_pvLivesInCircularBuffer[us] = 0x%x buffer length = %u wordlength = %u\n", us, m_pvLivesInCircularBuffer[us], pManager->get_live_in_jitter_buffer_length(pManager->user), m_usAudioEngineSampleWordLength);
|
|
+ //MTAL_DP("[%u] m_pvLivesInCircularBuffer[us] = 0x%x buffer length = %u wordlength = %u\n", us, self->m_pvLivesInCircularBuffer[us], self->m_pManager->get_live_in_jitter_buffer_length(self->m_pManager->user), self->m_usAudioEngineSampleWordLength);
|
|
|
|
if(self->m_pvLivesInCircularBuffer[us])
|
|
{ // mute
|
|
@@ -782,7 +783,7 @@ int ProcessRTPAudioPacket(TRTP_audio_stream* self, TRTPPacketBase* pRTPPacketBas
|
|
|
|
//MTAL_DP("ui32RTPSAC %u perfcounter %I64u\n", ui32RTPSAC, MTAL_LK_GetCounterTime());
|
|
// ui32UsedSAC is the first frame SAC when this packet will be used
|
|
- ui64UsedSAC = (ui64RTPSAC - (ui64RTPSAC % pManager->get_frame_size(pManager->user)));
|
|
+ ui64UsedSAC = (ui64RTPSAC - (CW_ll_modulo(ui64RTPSAC, pManager->get_frame_size(pManager->user))));
|
|
|
|
i64DeltaSAC = ui64UsedSAC - ui64GlobalSAC;
|
|
//MTAL_DP("i64DeltaSAC %I64u playout delay %u, frame size: %u\n", i64DeltaSAC, pRTP_stream_info->m_ui32PlayOutDelay, pManager->get_frame_size(pManager->user));
|
|
diff --git a/driver/manager.c b/driver/manager.c
|
|
index 5a90eca..8023708 100644
|
|
--- a/driver/manager.c
|
|
+++ b/driver/manager.c
|
|
@@ -1272,10 +1272,10 @@ uint32_t get_live_in_jitter_buffer_offset(void* user, const uint64_t ui64Current
|
|
struct TManager* self = (struct TManager*)user;
|
|
|
|
#if defined(MT_TONE_TEST) || defined (MT_RAMP_TEST) || defined (MTLOOPBACK) || defined (MTTRANSPARENCY_CHECK)
|
|
- return (uint32_t)(ui64CurrentSAC % get_live_in_jitter_buffer_length(self));
|
|
+ return (uint32_t)CW_ll_modulo(ui64CurrentSAC, get_live_in_jitter_buffer_length(self));
|
|
#else
|
|
uint32_t live_in_jitter_buffer_length = self->m_alsa_driver_frontend->get_capture_buffer_size_in_frames(self->m_pALSAChip);
|
|
- return (uint32_t)(ui64CurrentSAC % live_in_jitter_buffer_length);
|
|
+ return (uint32_t)CW_ll_modulo(ui64CurrentSAC, live_in_jitter_buffer_length);
|
|
#endif
|
|
}
|
|
|
|
@@ -1298,7 +1298,7 @@ uint32_t get_live_out_jitter_buffer_offset(void* user, const uint64_t ui64Curren
|
|
struct TManager* self = (struct TManager*)user;
|
|
|
|
#if defined(MT_TONE_TEST) || defined (MT_RAMP_TEST) || defined (MTLOOPBACK) || defined (MTTRANSPARENCY_CHECK)
|
|
- return (uint32_t)(ui64CurrentSAC % get_live_out_jitter_buffer_length(self));
|
|
+ return (uint32_t)CW_ll_modulo(ui64CurrentSAC, get_live_out_jitter_buffer_length(self));
|
|
#else
|
|
uint32_t offset = self->m_alsa_driver_frontend->get_playback_buffer_offset(self->m_pALSAChip);
|
|
const uint32_t sacOffset = (uint32_t)(get_global_SAC(self) - get_frame_size(self) - ui64CurrentSAC);
|
|
@@ -1432,9 +1432,9 @@ void AudioFrameTIC(void* user)
|
|
{
|
|
#if defined(MT_TONE_TEST)
|
|
unsigned long p = (self->m_tone_test_phase * self->m_SampleRate) / LUTSampleRate;
|
|
- int16_t val16 = LUT[(p + 4 * chIdx) % LUTnbPoints]/* >> 1*/;
|
|
+ int16_t val16 = LUT[CW_ll_modulo((p + 4 * chIdx), LUTnbPoints)]/* >> 1*/;
|
|
int32_t val24 = val16 << 8;
|
|
- self->m_tone_test_phase = (self->m_tone_test_phase + 1) % (LUTnbPoints * 100);
|
|
+ self->m_tone_test_phase = CW_ll_modulo((self->m_tone_test_phase + 1), (LUTnbPoints * 100));
|
|
#elif defined(MT_RAMP_TEST)
|
|
int32_t val24 = self->m_ramp_test_phase;
|
|
if(val24 >= 8388608) // 2^23
|
|
diff --git a/driver/MTAL_DP.h b/driver/MTAL_DP.h
|
|
index 1f0fb89..8aeaba2 100644
|
|
--- a/driver/MTAL_DP.h
|
|
+++ b/driver/MTAL_DP.h
|
|
@@ -129,26 +129,34 @@
|
|
#include <linux/version.h>
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
|
|
#include <linux/kern_levels.h>
|
|
- #define MTAL_DP(...) MTAL_LK_print(KERN_INFO __VA_ARGS__)
|
|
+ #define MTAL_DP(...)
|
|
+ //#define MTAL_DP(...) MTAL_LK_print(KERN_INFO __VA_ARGS__)
|
|
#define MTAL_DP_EMRG(...) MTAL_LK_print(KERN_EMERG __VA_ARGS__)
|
|
#define MTAL_DP_ALERT(...) MTAL_LK_print(KERN_ALERT __VA_ARGS__)
|
|
#define MTAL_DP_CRIT(...) MTAL_LK_print(KERN_CRIT __VA_ARGS__)
|
|
#define MTAL_DP_ERR(...) MTAL_LK_print(KERN_ERR __VA_ARGS__)
|
|
#define MTAL_DP_WARN(...) MTAL_LK_print(KERN_WARNING __VA_ARGS__)
|
|
- #define MTAL_DP_NOTICE(...) MTAL_LK_print(KERN_NOTICE __VA_ARGS__)
|
|
- #define MTAL_DP_INFO(...) MTAL_LK_print(KERN_INFO __VA_ARGS__)
|
|
- #define MTAL_DP_DEBUG(...) MTAL_LK_print(KERN_DEBUG __VA_ARGS__)
|
|
+ #define MTAL_DP_NOTICE(...)
|
|
+ //#define MTAL_DP_NOTICE(...) MTAL_LK_print(KERN_NOTICE __VA_ARGS__)
|
|
+ #define MTAL_DP_INFO(...)
|
|
+ //#define MTAL_DP_INFO(...) MTAL_LK_print(KERN_INFO __VA_ARGS__)
|
|
+ #define MTAL_DP_DEBUG(...)
|
|
+ //#define MTAL_DP_DEBUG(...) MTAL_LK_print(KERN_DEBUG __VA_ARGS__)
|
|
#else
|
|
//#include <linux/kernel.h>
|
|
- #define MTAL_DP(...) MTAL_LK_print("<d>"__VA_ARGS__)
|
|
+ #define MTAL_DP(...)
|
|
+ //#define MTAL_DP(...) MTAL_LK_print("<d>"__VA_ARGS__)
|
|
#define MTAL_DP_EMRG(...) MTAL_LK_print("<>"__VA_ARGS__)
|
|
#define MTAL_DP_ALERT(...) MTAL_LK_print("<1>"__VA_ARGS__)
|
|
#define MTAL_DP_CRIT(...) MTAL_LK_print("<2>"__VA_ARGS__)
|
|
#define MTAL_DP_ERR(...) MTAL_LK_print("<3>"__VA_ARGS__)
|
|
#define MTAL_DP_WARN(...) MTAL_LK_print("<4>"__VA_ARGS__)
|
|
- #define MTAL_DP_NOTICE(...) MTAL_LK_print("<5>"__VA_ARGS__)
|
|
- #define MTAL_DP_INFO(...) MTAL_LK_print("<6>"__VA_ARGS__)
|
|
- #define MTAL_DP_DEBUG(...) MTAL_LK_print("<7>"__VA_ARGS__)
|
|
+ #define MTAL_DP_NOTICE(...)
|
|
+ //#define MTAL_DP_NOTICE(...) MTAL_LK_print("<5>"__VA_ARGS__)
|
|
+ #define MTAL_DP_INFO(...)
|
|
+ //#define MTAL_DP_INFO(...) MTAL_LK_print("<6>"__VA_ARGS__)
|
|
+ #define MTAL_DP_DEBUG(...)
|
|
+ //#define MTAL_DP_DEBUG(...) MTAL_LK_print("<7>"__VA_ARGS__)
|
|
#endif
|
|
|
|
|
|
diff --git a/driver/MTConvert.c b/driver/MTConvert.c
|
|
index c94bc03..c9fdffe 100644
|
|
--- a/driver/MTConvert.c
|
|
+++ b/driver/MTConvert.c
|
|
@@ -1318,10 +1318,10 @@ int MTConvertMappedInt32ToInt16LEInterleave(void** input_buffer, const uint32_t
|
|
{
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[0], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[0], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1358,10 +1358,10 @@ int MTConvertMappedInt32ToInt16LEInterleave(void** input_buffer, const uint32_t
|
|
{
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[3], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[3], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1411,13 +1411,13 @@ int MTConvertMappedInt32ToInt24LEInterleave(void** input_buffer, const uint32_t
|
|
{
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[0], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[0], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1457,13 +1457,13 @@ int MTConvertMappedInt32ToInt24LEInterleave(void** input_buffer, const uint32_t
|
|
{
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[3], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[3], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1516,16 +1516,16 @@ int MTConvertMappedInt32ToInt24LE4ByteInterleave(void** input_buffer, const uint
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
char zero = 0x00;
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[0], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[0], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, zero, (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(zero, (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1568,16 +1568,16 @@ int MTConvertMappedInt32ToInt24LE4ByteInterleave(void** input_buffer, const uint
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
char zero = 0x00;
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[3], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[3], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, zero, (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(zero, (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1600,16 +1600,16 @@ int MTConvertMappedInt32ToInt24LE4ByteInterleave(void** input_buffer, const uint
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
char zero = 0x00;
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[3], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[3], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, zero, (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(zero, (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1648,16 +1648,16 @@ int MTConvertMappedInt32ToInt32LEInterleave(void** input_buffer, const uint32_t
|
|
{
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
- __put_user_x(1, in[3], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[3], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[0], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[0], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1699,16 +1699,16 @@ int MTConvertMappedInt32ToInt32LEInterleave(void** input_buffer, const uint32_t
|
|
{
|
|
const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos;
|
|
#if defined(MTAL_LINUX) && defined(MTAL_KERNEL)
|
|
- __put_user_x(1, in[0], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[0], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[1], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[1], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[2], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[2], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
- __put_user_x(1, in[3], (unsigned long __user *)out, ret_pu);
|
|
+ ret_pu = put_user(in[3], (unsigned char __user *)out);
|
|
ret |= ret_pu;
|
|
out++;
|
|
#else
|
|
@@ -1867,6 +1867,7 @@ void MTConvertBigEndianInt16ToMappedInt32DeInterleave( void* input_buffer,
|
|
uint32_t i, ch;
|
|
const unsigned int stride_in = 2 * nb_channels, stride_out = 4;
|
|
const unsigned int out_pos = offset_output_buf * stride_out;
|
|
+
|
|
for(ch = 0; ch < nb_channels; ++ch)
|
|
{
|
|
uint8_t* in = (uint8_t*)input_buffer + 2 * ch;
|