18c2ecf20Sopenharmony_ci============== 28c2ecf20Sopenharmony_ciAudio Clocking 38c2ecf20Sopenharmony_ci============== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThis text describes the audio clocking terms in ASoC and digital audio in 68c2ecf20Sopenharmony_cigeneral. Note: Audio clocking can be complex! 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciMaster Clock 108c2ecf20Sopenharmony_ci------------ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciEvery audio subsystem is driven by a master clock (sometimes referred to as MCLK 138c2ecf20Sopenharmony_cior SYSCLK). This audio master clock can be derived from a number of sources 148c2ecf20Sopenharmony_ci(e.g. crystal, PLL, CPU clock) and is responsible for producing the correct 158c2ecf20Sopenharmony_ciaudio playback and capture sample rates. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciSome master clocks (e.g. PLLs and CPU based clocks) are configurable in that 188c2ecf20Sopenharmony_citheir speed can be altered by software (depending on the system use and to save 198c2ecf20Sopenharmony_cipower). Other master clocks are fixed at a set frequency (i.e. crystals). 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciDAI Clocks 238c2ecf20Sopenharmony_ci---------- 248c2ecf20Sopenharmony_ciThe Digital Audio Interface is usually driven by a Bit Clock (often referred to 258c2ecf20Sopenharmony_cias BCLK). This clock is used to drive the digital audio data across the link 268c2ecf20Sopenharmony_cibetween the codec and CPU. 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ciThe DAI also has a frame clock to signal the start of each audio frame. This 298c2ecf20Sopenharmony_ciclock is sometimes referred to as LRC (left right clock) or FRAME. This clock 308c2ecf20Sopenharmony_ciruns at exactly the sample rate (LRC = Rate). 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciBit Clock can be generated as follows:- 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci- BCLK = MCLK / x, or 358c2ecf20Sopenharmony_ci- BCLK = LRC * x, or 368c2ecf20Sopenharmony_ci- BCLK = LRC * Channels * Word Size 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciThis relationship depends on the codec or SoC CPU in particular. In general 398c2ecf20Sopenharmony_ciit is best to configure BCLK to the lowest possible speed (depending on your 408c2ecf20Sopenharmony_cirate, number of channels and word size) to save on power. 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciIt is also desirable to use the codec (if possible) to drive (or master) the 438c2ecf20Sopenharmony_ciaudio clocks as it usually gives more accurate sample rates than the CPU. 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci 47