162306a36Sopenharmony_ci============== 262306a36Sopenharmony_ciAudio Clocking 362306a36Sopenharmony_ci============== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciThis text describes the audio clocking terms in ASoC and digital audio in 662306a36Sopenharmony_cigeneral. Note: Audio clocking can be complex! 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciMaster Clock 1062306a36Sopenharmony_ci------------ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciEvery audio subsystem is driven by a master clock (sometimes referred to as MCLK 1362306a36Sopenharmony_cior SYSCLK). This audio master clock can be derived from a number of sources 1462306a36Sopenharmony_ci(e.g. crystal, PLL, CPU clock) and is responsible for producing the correct 1562306a36Sopenharmony_ciaudio playback and capture sample rates. 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciSome master clocks (e.g. PLLs and CPU based clocks) are configurable in that 1862306a36Sopenharmony_citheir speed can be altered by software (depending on the system use and to save 1962306a36Sopenharmony_cipower). Other master clocks are fixed at a set frequency (i.e. crystals). 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciDAI Clocks 2362306a36Sopenharmony_ci---------- 2462306a36Sopenharmony_ciThe Digital Audio Interface is usually driven by a Bit Clock (often referred to 2562306a36Sopenharmony_cias BCLK). This clock is used to drive the digital audio data across the link 2662306a36Sopenharmony_cibetween the codec and CPU. 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ciThe DAI also has a frame clock to signal the start of each audio frame. This 2962306a36Sopenharmony_ciclock is sometimes referred to as LRC (left right clock) or FRAME. This clock 3062306a36Sopenharmony_ciruns at exactly the sample rate (LRC = Rate). 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciBit Clock can be generated as follows:- 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci- BCLK = MCLK / x, or 3562306a36Sopenharmony_ci- BCLK = LRC * x, or 3662306a36Sopenharmony_ci- BCLK = LRC * Channels * Word Size 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciThis relationship depends on the codec or SoC CPU in particular. In general 3962306a36Sopenharmony_ciit is best to configure BCLK to the lowest possible speed (depending on your 4062306a36Sopenharmony_cirate, number of channels and word size) to save on power. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciIt is also desirable to use the codec (if possible) to drive (or master) the 4362306a36Sopenharmony_ciaudio clocks as it usually gives more accurate sample rates than the CPU. 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci 47