Dear TI E2E Community,
Am hearing the clicks sound as soon as my GSM call ALSA application is started, I tried turning off the ADC & DAC in my stereo codec(UDA1345TS interfaced to davinci mcasp0) during bootup using amixer & then ran my GSM app, but still am hearing this issue
For your reference, I have hereby attached the GSM application & the asound.conf(modified for routing)
Application design
----------------------
GSM MIC [Analog Data]->GSM_PCM_OUT [Digital Data]->SDIN[Digital Data]->OUTP[Analog Data] ->VINR[Analog Data] ->I2S[Digital Data]-> VOUTR[Analog Data]-> Board Speaker[Analog Data]
GSM Speaker [Analog Data] <- GSM_PCM_IN[Digital Data] <- SDOUT[Digital Data] <- MICLP [Analog Data]<- VOUTL [Analog Data]<- I2S [Digital Data] <-VINL[Analog Data]<-Board MIC [Analog Data]
#include <stdio.h> #include <stdlib.h> #include <alsa/asoundlib.h> #define BUF_BYTES 128 int main (int argc, char *argv[]) { int err, rc ; unsigned char buf_right[BUF_BYTES]; unsigned char buf_left[BUF_BYTES]; //char *buf; int size; snd_pcm_t *playback_handle_right; snd_pcm_t *capture_handle_right; snd_pcm_t *playback_handle_left; snd_pcm_t *capture_handle_left; #if 0 char* device = "default"; if (argc > 1) device = argv[1]; #endif char* crdevice ; char* prdevice ; char* cldevice ; char* pldevice ; unsigned int rate ; unsigned int nchannels = 1; snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE; unsigned int buf_frames_right = BUF_BYTES / nchannels / 2; unsigned int buf_frames_left = BUF_BYTES / nchannels / 2; if(argc != 2 ) { printf("\nUsage is : application sampling_rate \n\n\t Ex: ./gsm_application_target 8000 \n\n\t Supported sampling rates are: \n\t 1) 8000 \n\t 2) 16000 \n\t 3) 32000 \n\t 4) 44100 \n\t 5) 48000 \n\n NOTE: Any number other than given sampling rate takes default as 48000\n\n"); exit(1); } rate = (int)atoi(argv[1]); if(rate == 8000) { crdevice = "VINR8"; prdevice = "VOUTR8"; cldevice = "VINL8"; pldevice = "VOUTL8"; }else if(rate == 16000) { crdevice = "VINR16"; prdevice = "VOUTR16"; cldevice = "VINL16"; pldevice = "VOUTL16"; }else if(rate == 32000) { crdevice = "VINR32"; prdevice = "VOUTR32"; cldevice = "VINL32"; pldevice = "VOUTL32"; }else if(rate == 44100) { crdevice = "VINR44"; prdevice = "VOUTR44"; cldevice = "VINL44"; pldevice = "VOUTL44"; }else { crdevice = "VINR48"; prdevice = "VOUTR48"; cldevice = "VINL48"; pldevice = "VOUTL48"; rate = 48000; } ///// RIGHT CHANNEL newStart: if ((err = snd_pcm_open (&playback_handle_right, prdevice, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { fprintf (stderr, "cannot open playback right audio device %s (%s)\n", prdevice, snd_strerror (err)); exit (1); } else { printf("Opened Playback right audio device successfully %s \n", prdevice); } if ((err = snd_pcm_set_params(playback_handle_right, format, SND_PCM_ACCESS_RW_INTERLEAVED, nchannels, rate, 1, 500000)) < 0) { /* 0.5sec */ fprintf(stderr, "Playback right open error: %s\n", snd_strerror(err)); exit(1); } if ((err = snd_pcm_open (&capture_handle_right, crdevice, SND_PCM_STREAM_CAPTURE, 0)) < 0) { fprintf (stderr, "cannot open capture right audio device %s (%s)\n", crdevice, snd_strerror (err)); exit (1); } else { printf("Opened Capture right audio device successfully %s \n", crdevice); } if ((err = snd_pcm_set_params(capture_handle_right, format, SND_PCM_ACCESS_RW_INTERLEAVED, nchannels, rate, 1, 500000)) < 0) { /* 0.5sec */ fprintf(stderr, "capture right open error: %s\n", snd_strerror(err)); exit(1); } ////LEFT CHANNEL if ((err = snd_pcm_open (&playback_handle_left, pldevice, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { fprintf (stderr, "cannot open playback left audio device %s (%s)\n", pldevice, snd_strerror (err)); exit (1); } else { printf("Opened Playback left audio device successfully %s \n", pldevice); } if ((err = snd_pcm_set_params(playback_handle_left, format, SND_PCM_ACCESS_RW_INTERLEAVED, nchannels, rate, 1, 500000)) < 0) { /* 0.5sec */ fprintf(stderr, "Playback left open error: %s\n", snd_strerror(err)); exit(1); } if ((err = snd_pcm_open (&capture_handle_left, cldevice, SND_PCM_STREAM_CAPTURE, 0)) < 0) { fprintf (stderr, "cannot open capture left audio device %s (%s)\n", cldevice, snd_strerror (err)); exit (1); } else { printf("Opened Capture left audio device successfully %s \n", crdevice); } if ((err = snd_pcm_set_params(capture_handle_left, format, SND_PCM_ACCESS_RW_INTERLEAVED, nchannels, rate, 1, 500000)) < 0) { /* 0.5sec */ fprintf(stderr, "capture left open error: %s\n", snd_strerror(err)); exit(1); } while(1) { ///// RIGHT CHANNEL /***** Read the Frames from the Capture Device ******/ err = snd_pcm_readi(capture_handle_right, buf_right, buf_frames_right); if(err == -EPIPE) { printf("capture right func: overrun!"); rc = snd_pcm_prepare(capture_handle_right); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err < 0) { fprintf (stderr, "read from audio interface right failed (%s)\n", snd_strerror (err)); rc = snd_pcm_recover(capture_handle_right,err,0); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err != (int)buf_frames_right) { fprintf(stderr, "short read, read %d frames\n", err); } /**** Write the capture frame to playback ******/ err = snd_pcm_writei (playback_handle_right, buf_right, buf_frames_right); if(err == -EPIPE) { printf("Playback right func: overrun!"); rc = snd_pcm_prepare(playback_handle_right); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err < 0) { fprintf (stderr, "write to audio interface right failed (%s)\n", snd_strerror (err)); rc = snd_pcm_recover(playback_handle_right, err, 0); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); //goto reStart; } }else if(err != (int)buf_frames_right) { fprintf(stderr, "short write, write %d frames\n", err); } ////LEFT CHANNEL /***** Read the Frames from the Capture Device ******/ err = snd_pcm_readi(capture_handle_left, buf_left, buf_frames_left); if(err == -EPIPE) { printf("capture right func: overrun!"); rc = snd_pcm_prepare(capture_handle_left); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err < 0) { fprintf (stderr, "read from audio interface right failed (%s)\n", snd_strerror (err)); rc = snd_pcm_recover(capture_handle_left,err,0); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err != (int)buf_frames_left) { fprintf(stderr, "short read, read %d frames\n", err); } /**** Write the capture frame to playback ******/ err = snd_pcm_writei (playback_handle_left, buf_left, buf_frames_left); if(err == -EPIPE) { printf("Playback right func: overrun!"); rc = snd_pcm_prepare(playback_handle_left); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err < 0) { fprintf (stderr, "write to audio interface right failed (%s)\n", snd_strerror (err)); rc = snd_pcm_recover(playback_handle_left, err, 0); if(rc < 0) { printf("Fail to recover from problem, Need to reopen the device\n"); // goto reStart; } }else if(err != (int)buf_frames_left) { fprintf(stderr, "short write, write %d frames\n", err); } } reStart: fprintf (stderr, "close handles\n"); snd_pcm_close (playback_handle_right); snd_pcm_close (capture_handle_right); snd_pcm_close (playback_handle_left); snd_pcm_close (capture_handle_left); sleep(2); //goto newStart; return 0; }
#This configuration for 3.14 kernel pcm.card0 { type hw card 0 } ctl.card0 { type hw card 0 } ###Dshare pcm.VOUTL8 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 8000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 0 } } pcm.VOUTR8 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 8000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 1 } } ### Dsnoop splited channels pcm.VINL8 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 8000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 0 } pcm.VINR8 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 8000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 1 } ###Dshare 16k pcm.VOUTL16 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 16000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 0 } } pcm.VOUTR16 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 16000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 1 } } ### Dsnoop splited channels pcm.VINL16 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 16000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 0 } pcm.VINR16 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 16000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 1 } ###Dshare 32k pcm.VOUTL32 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 32000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 0 } } pcm.VOUTR32 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 32000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 1 } } ### Dsnoop splited channels pcm.VINL32 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 32000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 0 } pcm.VINR32 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 32000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 1 } ###Dshare 44k pcm.VOUTL44 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 44100 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 0 } } pcm.VOUTR44 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 44100 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 1 } } ### Dsnoop splited channels pcm.VINL44 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 44100 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 0 } pcm.VINR44 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 44100 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 1 } ###Dshare 48k pcm.VOUTL48 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 48000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 0 } } pcm.VOUTR48 { type dshare ipc_key 6678293 ipc_key_add_uid yes slave { pcm "hw:0,0" rate 48000 buffer_size 4097 period_size 1000 period_time 125000 } bindings { 0 1 } } ### Dsnoop splited channels pcm.VINL48 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 48000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 0 } pcm.VINR48 { type dsnoop ipc_key 32 slave { pcm "hw:0,0" rate 48000 buffer_size 4097 period_size 1000 period_time 125000 channels 2 } bindings.0 1 } pcm.!default VOUTR8 pcm.!default VOUTL8 pcm.!default VOUTR16 pcm.!default VOUTL16 pcm.!default VOUTR32 pcm.!default VOUTL32 pcm.!default VOUTR44 pcm.!default VOUTL44 pcm.!default VOUTR48 pcm.!default VOUTL48
Could you please help me out or provide any valuable inputs or guidance w.r.t the issue
Other option am thinking is to turn off the ADC & DAC in stereo codec inside the GSM app
Kindly do the needful as early as possible,
Many thanks in advance