AnsweredAssumed Answered

sc584-ezboard play wav file

Question asked by jeffxu on Nov 17, 2016
Latest reply on Nov 21, 2016 by Gregchen

I'm using aplay to play audio file ,when I play wav file , the log is :

 

# aplay -l                                                                      
**** List of PLAYBACK Hardware Devices ****                                     
card 1: sc58xadau1962 [sc58x-adau1962], device 0: ADAU1962 adau1962-hifi-0 []   
  Subdevices: 1/1                                                               
  Subdevice #0: subdevice #0   

# aplay -D hw:1,0 02.wav                                                        
Playing WAVE '02.wav' : adau1962 0-0004: ASoC: can't set adau1962-hifi hw param2
Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                              
aplay: set_params:1297: Unable to install hw params:                            
ACCESS:  RW_INTERLEAVED                                                         
FORMAT:  S16_LE                                                                 
SUBFORMAT:  STD                                                                 
SAMPLE_BITS: 16                                                                 
FRAME_BITS: 32                                                                  
CHANNELS: 2                                                                     
RATE: 44100                                                                     
PERIOD_TIME: (125011 125012)                                                    
PERIOD_SIZE: 5513                                                               
PERIOD_BYTES: 22052                                                             
PERIODS: 4                                                                      
BUFFER_TIME: (500045 500046)                                                    
BUFFER_SIZE: 22052                                                              
BUFFER_BYTES: 88208                                                             
TICK_TIME: 0 

 

In the linux source code,I found when adau1962_hw_params() execute adau1962_lookup_mcs(),

the function adau1962_lookup_mcs() return -22.

 

static int adau1962_lookup_mcs(struct adau1962 *adau1962, unsigned int rate,
    unsigned int fs)
{
    unsigned int mcs;

    rate *= 128 >> fs;

    if (adau1962->sysclk % rate != 0) //adau1962->sysclk = 24576000,rate=44100*128,

                                                            //so adau1962->sysclk % rate != 0,return -22
        return -EINVAL;

    mcs = adau1962->sysclk / rate;

    /* The factors configured by MCS are 2, 3, 4, 6 */
    if (mcs < 2 || mcs > 6 || mcs == 5)
        return -EINVAL;

    mcs = mcs - 2;
    if (mcs == 4)
        mcs = 3;

    return mcs;
}

 

If I change sysclk to 22579200, aplay can play my wav file which sample rate is 44100

--- a/buildroot/linux/linux-kernel/sound/soc/adi/sc58x-adau1962.c
+++ b/buildroot/linux/linux-kernel/sound/soc/adi/sc58x-adau1962.c
@@ -28,7 +28,7 @@
 static int sc58x_adau1962_init(struct snd_soc_pcm_runtime *rtd)
 {
        return snd_soc_codec_set_sysclk(rtd->codec, ADAU1962_SYSCLK,
-                       ADAU1962_SYSCLK_SRC_MCLK, 24576000, SND_SOC_CLOCK_IN);
+                       ADAU1962_SYSCLK_SRC_MCLK, 22579200, SND_SOC_CLOCK_IN);
 }

 

could you tell me how to fix this problem?

how can I handle other file?for example sample rate is 48000,32000...

 

Outcomes