1*4882a593Smuzhiyun============== 2*4882a593SmuzhiyunAudio Clocking 3*4882a593Smuzhiyun============== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunThis text describes the audio clocking terms in ASoC and digital audio in 6*4882a593Smuzhiyungeneral. Note: Audio clocking can be complex! 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunMaster Clock 10*4882a593Smuzhiyun------------ 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunEvery audio subsystem is driven by a master clock (sometimes referred to as MCLK 13*4882a593Smuzhiyunor SYSCLK). This audio master clock can be derived from a number of sources 14*4882a593Smuzhiyun(e.g. crystal, PLL, CPU clock) and is responsible for producing the correct 15*4882a593Smuzhiyunaudio playback and capture sample rates. 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunSome master clocks (e.g. PLLs and CPU based clocks) are configurable in that 18*4882a593Smuzhiyuntheir speed can be altered by software (depending on the system use and to save 19*4882a593Smuzhiyunpower). Other master clocks are fixed at a set frequency (i.e. crystals). 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunDAI Clocks 23*4882a593Smuzhiyun---------- 24*4882a593SmuzhiyunThe Digital Audio Interface is usually driven by a Bit Clock (often referred to 25*4882a593Smuzhiyunas BCLK). This clock is used to drive the digital audio data across the link 26*4882a593Smuzhiyunbetween the codec and CPU. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunThe DAI also has a frame clock to signal the start of each audio frame. This 29*4882a593Smuzhiyunclock is sometimes referred to as LRC (left right clock) or FRAME. This clock 30*4882a593Smuzhiyunruns at exactly the sample rate (LRC = Rate). 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunBit Clock can be generated as follows:- 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun- BCLK = MCLK / x, or 35*4882a593Smuzhiyun- BCLK = LRC * x, or 36*4882a593Smuzhiyun- BCLK = LRC * Channels * Word Size 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunThis relationship depends on the codec or SoC CPU in particular. In general 39*4882a593Smuzhiyunit is best to configure BCLK to the lowest possible speed (depending on your 40*4882a593Smuzhiyunrate, number of channels and word size) to save on power. 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunIt is also desirable to use the codec (if possible) to drive (or master) the 43*4882a593Smuzhiyunaudio clocks as it usually gives more accurate sample rates than the CPU. 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun 47