1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2021 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_WM8960_H_
10 #define _FSL_WM8960_H_
11 
12 #include "fsl_codec_i2c.h"
13 #include "fsl_common.h"
14 
15 /*!
16  * @addtogroup wm8960
17  * @ingroup codec
18  * @{
19  */
20 
21 /*******************************************************************************
22  * Definitions
23  ******************************************************************************/
24 /*! @name Driver version */
25 /*@{*/
26 /*! @brief CLOCK driver version 2.2.2 */
27 #define FSL_WM8960_DRIVER_VERSION (MAKE_VERSION(2, 2, 2))
28 /*@}*/
29 
30 /*! @brief wm8960 handle size */
31 #ifndef WM8960_I2C_HANDLER_SIZE
32 #define WM8960_I2C_HANDLER_SIZE CODEC_I2C_MASTER_HANDLER_SIZE
33 #endif
34 
35 /*! @brief Define the register address of WM8960. */
36 #define WM8960_LINVOL  0x0U
37 #define WM8960_RINVOL  0x1U
38 #define WM8960_LOUT1   0x2U
39 #define WM8960_ROUT1   0x3U
40 #define WM8960_CLOCK1  0x4U
41 #define WM8960_DACCTL1 0x5U
42 #define WM8960_DACCTL2 0x6U
43 #define WM8960_IFACE1  0x7U
44 #define WM8960_CLOCK2  0x8U
45 #define WM8960_IFACE2  0x9U
46 #define WM8960_LDAC    0xaU
47 #define WM8960_RDAC    0xbU
48 
49 #define WM8960_RESET   0xfU
50 #define WM8960_3D      0x10U
51 #define WM8960_ALC1    0x11U
52 #define WM8960_ALC2    0x12U
53 #define WM8960_ALC3    0x13U
54 #define WM8960_NOISEG  0x14U
55 #define WM8960_LADC    0x15U
56 #define WM8960_RADC    0x16U
57 #define WM8960_ADDCTL1 0x17U
58 #define WM8960_ADDCTL2 0x18U
59 #define WM8960_POWER1  0x19U
60 #define WM8960_POWER2  0x1aU
61 #define WM8960_ADDCTL3 0x1bU
62 #define WM8960_APOP1   0x1cU
63 #define WM8960_APOP2   0x1dU
64 
65 #define WM8960_LINPATH 0x20U
66 #define WM8960_RINPATH 0x21U
67 #define WM8960_LOUTMIX 0x22U
68 
69 #define WM8960_ROUTMIX  0x25U
70 #define WM8960_MONOMIX1 0x26U
71 #define WM8960_MONOMIX2 0x27U
72 #define WM8960_LOUT2    0x28U
73 #define WM8960_ROUT2    0x29U
74 #define WM8960_MONO     0x2aU
75 #define WM8960_INBMIX1  0x2bU
76 #define WM8960_INBMIX2  0x2cU
77 #define WM8960_BYPASS1  0x2dU
78 #define WM8960_BYPASS2  0x2eU
79 #define WM8960_POWER3   0x2fU
80 #define WM8960_ADDCTL4  0x30U
81 #define WM8960_CLASSD1  0x31U
82 
83 #define WM8960_CLASSD3 0x33U
84 #define WM8960_PLL1    0x34U
85 #define WM8960_PLL2    0x35U
86 #define WM8960_PLL3    0x36U
87 #define WM8960_PLL4    0x37U
88 
89 /*! @brief Cache register number */
90 #define WM8960_CACHEREGNUM 56U
91 
92 /*! @brief WM8960 CLOCK2 bits */
93 #define WM8960_CLOCK2_BCLK_DIV_MASK 0xFU
94 
95 /*! @brief WM8960_IFACE1 FORMAT bits */
96 #define WM8960_IFACE1_FORMAT_MASK  0x03U
97 #define WM8960_IFACE1_FORMAT_SHIFT 0x00U
98 #define WM8960_IFACE1_FORMAT_RJ    0x00U
99 #define WM8960_IFACE1_FORMAT_LJ    0x01U
100 #define WM8960_IFACE1_FORMAT_I2S   0x02U
101 #define WM8960_IFACE1_FORMAT_DSP   0x03U
102 #define WM8960_IFACE1_FORMAT(x)    (((x) << WM8960_IFACE1_FORMAT_SHIFT) & WM8960_IFACE1_FORMAT_MASK)
103 
104 /*! @brief WM8960_IFACE1 WL bits */
105 #define WM8960_IFACE1_WL_MASK   0x0CU
106 #define WM8960_IFACE1_WL_SHIFT  0x02U
107 #define WM8960_IFACE1_WL_16BITS 0x00U
108 #define WM8960_IFACE1_WL_20BITS 0x01U
109 #define WM8960_IFACE1_WL_24BITS 0x02U
110 #define WM8960_IFACE1_WL_32BITS 0x03U
111 #define WM8960_IFACE1_WL(x)     (((x) << WM8960_IFACE1_WL_SHIFT) & WM8960_IFACE1_WL_MASK)
112 
113 /*! @brief WM8960_IFACE1 LRP bit */
114 #define WM8960_IFACE1_LRP_MASK         0x10U
115 #define WM8960_IFACE1_LRP_SHIFT        0x04U
116 #define WM8960_IFACE1_LRCLK_NORMAL_POL 0x00U
117 #define WM8960_IFACE1_LRCLK_INVERT_POL 0x01U
118 #define WM8960_IFACE1_DSP_MODEA        0x00U
119 #define WM8960_IFACE1_DSP_MODEB        0x01U
120 #define WM8960_IFACE1_LRP(x)           (((x) << WM8960_IFACE1_LRP_SHIFT) & WM8960_IFACE1_LRP_MASK)
121 
122 /*! @brief WM8960_IFACE1 DLRSWAP bit */
123 #define WM8960_IFACE1_DLRSWAP_MASK  0x20U
124 #define WM8960_IFACE1_DLRSWAP_SHIFT 0x05U
125 #define WM8960_IFACE1_DACCH_NORMAL  0x00U
126 #define WM8960_IFACE1_DACCH_SWAP    0x01U
127 #define WM8960_IFACE1_DLRSWAP(x)    (((x) << WM8960_IFACE1_DLRSWAP_SHIFT) & WM8960_IFACE1_DLRSWAP_MASK)
128 
129 /*! @brief WM8960_IFACE1 MS bit */
130 #define WM8960_IFACE1_MS_MASK  0x40U
131 #define WM8960_IFACE1_MS_SHIFT 0x06U
132 #define WM8960_IFACE1_SLAVE    0x00U
133 #define WM8960_IFACE1_MASTER   0x01U
134 #define WM8960_IFACE1_MS(x)    (((x) << WM8960_IFACE1_MS_SHIFT) & WM8960_IFACE1_MS_MASK)
135 
136 /*! @brief WM8960_IFACE1 BCLKINV bit */
137 #define WM8960_IFACE1_BCLKINV_MASK   0x80U
138 #define WM8960_IFACE1_BCLKINV_SHIFT  0x07U
139 #define WM8960_IFACE1_BCLK_NONINVERT 0x00U
140 #define WM8960_IFACE1_BCLK_INVERT    0x01U
141 #define WM8960_IFACE1_BCLKINV(x)     (((x) << WM8960_IFACE1_BCLKINV_SHIFT) & WM8960_IFACE1_BCLKINV_MASK)
142 
143 /*! @brief WM8960_IFACE1 ALRSWAP bit */
144 #define WM8960_IFACE1_ALRSWAP_MASK  0x100U
145 #define WM8960_IFACE1_ALRSWAP_SHIFT 0x08U
146 #define WM8960_IFACE1_ADCCH_NORMAL  0x00U
147 #define WM8960_IFACE1_ADCCH_SWAP    0x01U
148 #define WM8960_IFACE1_ALRSWAP(x)    (((x) << WM8960_IFACE1_ALRSWAP_SHIFT) & WM8960_IFACE1_ALRSWAP_MASK)
149 
150 /*! @brief WM8960_POWER1 */
151 #define WM8960_POWER1_VREF_MASK  0x40U
152 #define WM8960_POWER1_VREF_SHIFT 0x06U
153 
154 #define WM8960_POWER1_AINL_MASK  0x20U
155 #define WM8960_POWER1_AINL_SHIFT 0x05U
156 
157 #define WM8960_POWER1_AINR_MASK  0x10U
158 #define WM8960_POWER1_AINR_SHIFT 0x04U
159 
160 #define WM8960_POWER1_ADCL_MASK  0x08U
161 #define WM8960_POWER1_ADCL_SHIFT 0x03U
162 
163 #define WM8960_POWER1_ADCR_MASK  0x0U
164 #define WM8960_POWER1_ADCR_SHIFT 0x02U
165 
166 #define WM8960_POWER1_MICB_MASK  0x02U
167 #define WM8960_POWER1_MICB_SHIFT 0x01U
168 
169 #define WM8960_POWER1_DIGENB_MASK  0x01U
170 #define WM8960_POWER1_DIGENB_SHIFT 0x00U
171 
172 /*! @brief WM8960_POWER2 */
173 #define WM8960_POWER2_DACL_MASK  0x100U
174 #define WM8960_POWER2_DACL_SHIFT 0x08U
175 
176 #define WM8960_POWER2_DACR_MASK  0x80U
177 #define WM8960_POWER2_DACR_SHIFT 0x07U
178 
179 #define WM8960_POWER2_LOUT1_MASK  0x40U
180 #define WM8960_POWER2_LOUT1_SHIFT 0x06U
181 
182 #define WM8960_POWER2_ROUT1_MASK  0x20U
183 #define WM8960_POWER2_ROUT1_SHIFT 0x05U
184 
185 #define WM8960_POWER2_SPKL_MASK  0x10U
186 #define WM8960_POWER2_SPKL_SHIFT 0x04U
187 
188 #define WM8960_POWER2_SPKR_MASK  0x08U
189 #define WM8960_POWER2_SPKR_SHIFT 0x03U
190 
191 #define WM8960_POWER3_LMIC_MASK   0x20U
192 #define WM8960_POWER3_LMIC_SHIFT  0x05U
193 #define WM8960_POWER3_RMIC_MASK   0x10U
194 #define WM8960_POWER3_RMIC_SHIFT  0x04U
195 #define WM8960_POWER3_LOMIX_MASK  0x08U
196 #define WM8960_POWER3_LOMIX_SHIFT 0x03U
197 #define WM8960_POWER3_ROMIX_MASK  0x04U
198 #define WM8960_POWER3_ROMIX_SHIFT 0x02U
199 /*! @brief WM8960 I2C address. */
200 #define WM8960_I2C_ADDR 0x1A
201 /*! @brief WM8960 I2C baudrate */
202 #define WM8960_I2C_BAUDRATE (100000U)
203 /*! @brief WM8960 maximum volume value */
204 #define WM8960_ADC_MAX_VOLUME_vALUE       0xFFU
205 #define WM8960_DAC_MAX_VOLUME_vALUE       0xFFU
206 #define WM8960_HEADPHONE_MAX_VOLUME_vALUE 0x7FU
207 #define WM8960_HEADPHONE_MIN_VOLUME_vALUE 0x30U
208 #define WM8960_LINEIN_MAX_VOLUME_vALUE    0x3FU
209 #define WM8960_SPEAKER_MAX_VOLUME_vALUE   0x7FU
210 #define WM8960_SPEAKER_MIN_VOLUME_vALUE   0x30U
211 
212 /*! @brief Modules in WM8960 board. */
213 typedef enum _wm8960_module
214 {
215     kWM8960_ModuleADC     = 0, /*!< ADC module in WM8960 */
216     kWM8960_ModuleDAC     = 1, /*!< DAC module in WM8960 */
217     kWM8960_ModuleVREF    = 2, /*!< VREF module */
218     kWM8960_ModuleHP      = 3, /*!< Headphone */
219     kWM8960_ModuleMICB    = 4, /*!< Mic bias */
220     kWM8960_ModuleMIC     = 5, /*!< Input Mic */
221     kWM8960_ModuleLineIn  = 6, /*!< Analog in PGA  */
222     kWM8960_ModuleLineOut = 7, /*!< Line out module */
223     kWM8960_ModuleSpeaker = 8, /*!< Speaker module */
224     kWM8960_ModuleOMIX    = 9, /*!< Output mixer */
225 } wm8960_module_t;
226 
227 /*! @brief wm8960 play channel
228  * @anchor _wm8960_play_channel
229  */
230 enum
231 {
232     kWM8960_HeadphoneLeft  = 1, /*!< wm8960 headphone left channel */
233     kWM8960_HeadphoneRight = 2, /*!< wm8960 headphone right channel */
234     kWM8960_SpeakerLeft    = 4, /*!< wm8960 speaker left channel */
235     kWM8960_SpeakerRight   = 8, /*!< wm8960 speaker right channel */
236 };
237 
238 /*! @brief wm8960 play source */
239 typedef enum _wm8960_play_source
240 {
241     kWM8960_PlaySourcePGA   = 1, /*!< wm8960 play source PGA */
242     kWM8960_PlaySourceInput = 2, /*!< wm8960 play source Input */
243     kWM8960_PlaySourceDAC   = 4, /*!< wm8960 play source DAC */
244 } wm8960_play_source_t;
245 
246 /*!
247  * @brief WM8960 data route.
248  * Only provide some typical data route, not all route listed.
249  * Note: Users cannot combine any routes, once a new route is set, the previous one would be replaced.
250  */
251 typedef enum _wm8960_route
252 {
253     kWM8960_RouteBypass            = 0, /*!< LINEIN->Headphone. */
254     kWM8960_RoutePlayback          = 1, /*!<  I2SIN->DAC->Headphone. */
255     kWM8960_RoutePlaybackandRecord = 2, /*!< I2SIN->DAC->Headphone, LINEIN->ADC->I2SOUT. */
256     kWM8960_RouteRecord            = 5  /*!< LINEIN->ADC->I2SOUT. */
257 } wm8960_route_t;
258 
259 /*!
260  * @brief The audio data transfer protocol choice.
261  * WM8960 only supports I2S format and PCM format.
262  */
263 typedef enum _wm8960_protocol
264 {
265     kWM8960_BusI2S            = 2,           /*!< I2S type */
266     kWM8960_BusLeftJustified  = 1,           /*!< Left justified mode */
267     kWM8960_BusRightJustified = 0,           /*!< Right justified mode */
268     kWM8960_BusPCMA           = 3,           /*!< PCM A mode */
269     kWM8960_BusPCMB           = 3 | (1 << 4) /*!< PCM B mode */
270 } wm8960_protocol_t;
271 
272 /*! @brief wm8960 input source */
273 typedef enum _wm8960_input
274 {
275     kWM8960_InputClosed                = 0, /*!< Input device is closed */
276     kWM8960_InputSingleEndedMic        = 1, /*!< Input as single ended mic, only use L/RINPUT1 */
277     kWM8960_InputDifferentialMicInput2 = 2, /*!< Input as differential mic, use L/RINPUT1 and L/RINPUT2 */
278     kWM8960_InputDifferentialMicInput3 = 3, /*!< Input as differential mic, use L/RINPUT1 and L/RINPUT3*/
279     kWM8960_InputLineINPUT2            = 4, /*!< Input as line input, only use L/RINPUT2 */
280     kWM8960_InputLineINPUT3            = 5  /*!< Input as line input, only use L/RINPUT3 */
281 } wm8960_input_t;
282 
283 /*! @brief audio sample rate definition
284  * @anchor _wm8960_sample_rate
285  */
286 enum
287 {
288     kWM8960_AudioSampleRate8KHz    = 8000U,   /*!< Sample rate 8000 Hz */
289     kWM8960_AudioSampleRate11025Hz = 11025U,  /*!< Sample rate 11025 Hz */
290     kWM8960_AudioSampleRate12KHz   = 12000U,  /*!< Sample rate 12000 Hz */
291     kWM8960_AudioSampleRate16KHz   = 16000U,  /*!< Sample rate 16000 Hz */
292     kWM8960_AudioSampleRate22050Hz = 22050U,  /*!< Sample rate 22050 Hz */
293     kWM8960_AudioSampleRate24KHz   = 24000U,  /*!< Sample rate 24000 Hz */
294     kWM8960_AudioSampleRate32KHz   = 32000U,  /*!< Sample rate 32000 Hz */
295     kWM8960_AudioSampleRate44100Hz = 44100U,  /*!< Sample rate 44100 Hz */
296     kWM8960_AudioSampleRate48KHz   = 48000U,  /*!< Sample rate 48000 Hz */
297     kWM8960_AudioSampleRate96KHz   = 96000U,  /*!< Sample rate 96000 Hz */
298     kWM8960_AudioSampleRate192KHz  = 192000U, /*!< Sample rate 192000 Hz */
299     kWM8960_AudioSampleRate384KHz  = 384000U, /*!< Sample rate 384000 Hz */
300 };
301 
302 /*! @brief audio bit width
303  * @anchor _wm8960_audio_bit_width
304  */
305 enum
306 {
307     kWM8960_AudioBitWidth16bit = 16U, /*!< audio bit width 16 */
308     kWM8960_AudioBitWidth20bit = 20U, /*!< audio bit width 20 */
309     kWM8960_AudioBitWidth24bit = 24U, /*!< audio bit width 24 */
310     kWM8960_AudioBitWidth32bit = 32U, /*!< audio bit width 32 */
311 };
312 
313 /*! @brief wm8960 sysclk source */
314 typedef enum _wm8960_sysclk_source
315 {
316     kWM8960_SysClkSourceMclk        = 0U, /*!< sysclk source from external MCLK */
317     kWM8960_SysClkSourceInternalPLL = 1U, /*!< sysclk source from internal PLL */
318 } wm8960_sysclk_source_t;
319 
320 /*! @brief wm8960 audio format */
321 typedef struct _wm8960_audio_format
322 {
323     uint32_t mclk_HZ;    /*!< master clock frequency */
324     uint32_t sampleRate; /*!< sample rate */
325     uint32_t bitWidth;   /*!< bit width */
326 } wm8960_audio_format_t;
327 
328 /*! @brief wm8960 master system clock configuration */
329 typedef struct _wm8960_master_sysclk_config
330 {
331     wm8960_sysclk_source_t sysclkSource; /*!< sysclk source */
332     uint32_t sysclkFreq;                 /*!< PLL output frequency value */
333 } wm8960_master_sysclk_config_t;
334 
335 /*! @brief Initialize structure of WM8960 */
336 typedef struct wm8960_config
337 {
338     wm8960_route_t route;                      /*!< Audio data route.*/
339     wm8960_protocol_t bus;                     /*!< Audio transfer protocol */
340     wm8960_audio_format_t format;              /*!< Audio format */
341     bool master_slave;                         /*!< Master or slave. */
342     wm8960_master_sysclk_config_t masterClock; /*!< master clock configurations */
343     bool enableSpeaker;                        /*!< True means enable class D speaker as output, false means no */
344     wm8960_input_t leftInputSource;            /*!< Left input source for WM8960 */
345     wm8960_input_t rightInputSource;           /*!< Right input source for wm8960 */
346     wm8960_play_source_t playSource;           /*!< play source */
347     uint8_t slaveAddress;                      /*!< wm8960 device address */
348     codec_i2c_config_t i2cConfig;              /*!< i2c configuration */
349 } wm8960_config_t;
350 
351 /*! @brief wm8960 codec handler
352  */
353 typedef struct _wm8960_handle
354 {
355     const wm8960_config_t *config;              /*!< wm8904 config pointer */
356     uint8_t i2cHandle[WM8960_I2C_HANDLER_SIZE]; /*!< i2c handle */
357 } wm8960_handle_t;
358 /*******************************************************************************
359  * API
360  ******************************************************************************/
361 #if defined(__cplusplus)
362 extern "C" {
363 #endif
364 
365 /*!
366  * @brief WM8960 initialize function.
367  *
368  * The second parameter is NULL to WM8960 in this version. If users want
369  * to change the settings, they have to use wm8960_write_reg() or wm8960_modify_reg()
370  * to set the register value of WM8960.
371  * Note: If the codec_config is NULL, it would initialize WM8960 using default settings.
372  * The default setting:
373  * codec_config->route = kWM8960_RoutePlaybackandRecord
374  * codec_config->bus = kWM8960_BusI2S
375  * codec_config->master = slave
376  *
377  * @param handle WM8960 handle structure.
378  * @param config WM8960 configuration structure.
379  */
380 status_t WM8960_Init(wm8960_handle_t *handle, const wm8960_config_t *config);
381 
382 /*!
383  * @brief Deinit the WM8960 codec.
384  *
385  * This function close all modules in WM8960 to save power.
386  *
387  * @param handle WM8960 handle structure pointer.
388  */
389 status_t WM8960_Deinit(wm8960_handle_t *handle);
390 
391 /*!
392  * @brief Set audio data route in WM8960.
393  *
394  * This function would set the data route according to route. The route cannot be combined,
395  * as all route would enable different modules.
396  * Note: If a new route is set, the previous route would not work.
397  *
398  * @param handle WM8960 handle structure.
399  * @param route Audio data route in WM8960.
400  */
401 status_t WM8960_SetDataRoute(wm8960_handle_t *handle, wm8960_route_t route);
402 
403 /*!
404  * @brief Set left audio input source in WM8960.
405  *
406  * @param handle WM8960 handle structure.
407  * @param input Audio input source.
408  */
409 status_t WM8960_SetLeftInput(wm8960_handle_t *handle, wm8960_input_t input);
410 
411 /*!
412  * @brief Set right audio input source in WM8960.
413  *
414  * @param handle WM8960 handle structure.
415  * @param input Audio input source.
416  */
417 status_t WM8960_SetRightInput(wm8960_handle_t *handle, wm8960_input_t input);
418 
419 /*!
420  * @brief Set the audio transfer protocol.
421  *
422  * WM8960 only supports I2S, left justified, right justified, PCM A, PCM B format.
423  *
424  * @param handle WM8960 handle structure.
425  * @param protocol Audio data transfer protocol.
426  */
427 status_t WM8960_SetProtocol(wm8960_handle_t *handle, wm8960_protocol_t protocol);
428 
429 /*!
430  * @brief Set WM8960 as master or slave.
431  *
432  * @param handle WM8960 handle structure.
433  * @param master 1 represent master, 0 represent slave.
434  */
435 void WM8960_SetMasterSlave(wm8960_handle_t *handle, bool master);
436 
437 /*!
438  * @brief Set the volume of different modules in WM8960.
439  *
440  * This function would set the volume of WM8960 modules. Uses need to appoint the module.
441  * The function assume that left channel and right channel has the same volume.
442  *
443  * Module:kWM8960_ModuleADC, volume range value: 0 is mute, 1-255 is -97db to 30db
444  * Module:kWM8960_ModuleDAC, volume range value: 0 is mute, 1-255 is -127db to 0db
445  * Module:kWM8960_ModuleHP, volume range value: 0 - 2F is mute, 0x30 - 0x7F is -73db to 6db
446  * Module:kWM8960_ModuleLineIn, volume range value: 0 - 0x3F is -17.25db to 30db
447  * Module:kWM8960_ModuleSpeaker, volume range value: 0 - 2F is mute, 0x30 - 0x7F is -73db to 6db
448  *
449  *
450  * @param handle WM8960 handle structure.
451  * @param module Module to set volume, it can be ADC, DAC, Headphone and so on.
452  * @param volume Volume value need to be set.
453  */
454 status_t WM8960_SetVolume(wm8960_handle_t *handle, wm8960_module_t module, uint32_t volume);
455 
456 /*!
457  * @brief Get the volume of different modules in WM8960.
458  *
459  * This function gets the volume of WM8960 modules. Uses need to appoint the module.
460  * The function assume that left channel and right channel has the same volume.
461  *
462  * @param handle WM8960 handle structure.
463  * @param module Module to set volume, it can be ADC, DAC, Headphone and so on.
464  * @return Volume value of the module.
465  */
466 uint32_t WM8960_GetVolume(wm8960_handle_t *handle, wm8960_module_t module);
467 
468 /*!
469  * @brief Mute modules in WM8960.
470  *
471  * @param handle WM8960 handle structure.
472  * @param module Modules need to be mute.
473  * @param isEnabled Mute or unmute, 1 represent mute.
474  */
475 status_t WM8960_SetMute(wm8960_handle_t *handle, wm8960_module_t module, bool isEnabled);
476 
477 /*!
478  * @brief Enable/disable expected devices.
479  *
480  * @param handle WM8960 handle structure.
481  * @param module Module expected to enable.
482  * @param isEnabled Enable or disable moudles.
483  */
484 status_t WM8960_SetModule(wm8960_handle_t *handle, wm8960_module_t module, bool isEnabled);
485 
486 /*!
487  * @brief SET the WM8960 play source.
488  *
489  * @param handle WM8960 handle structure.
490  * @param playSource play source , can be a value combine of kWM8960_ModuleHeadphoneSourcePGA,
491  * kWM8960_ModuleHeadphoneSourceDAC, kWM8960_ModulePlaySourceInput, kWM8960_ModulePlayMonoRight,
492  * kWM8960_ModulePlayMonoLeft.
493  *
494  * @return kStatus_WM8904_Success if successful, different code otherwise..
495  */
496 status_t WM8960_SetPlay(wm8960_handle_t *handle, uint32_t playSource);
497 
498 /*!
499  * @brief Configure the data format of audio data.
500  *
501  * This function would configure the registers about the sample rate, bit depths.
502  *
503  * @param handle WM8960 handle structure pointer.
504  * @param sysclk system clock of the codec which can be generated by MCLK or PLL output.
505  * @param sample_rate Sample rate of audio file running in WM8960. WM8960 now
506  * supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate.
507  * @param bits Bit depth of audio file (WM8960 only supports 16bit, 20bit, 24bit
508  * and 32 bit in HW).
509  */
510 status_t WM8960_ConfigDataFormat(wm8960_handle_t *handle, uint32_t sysclk, uint32_t sample_rate, uint32_t bits);
511 
512 /*!
513  * @brief Enable/disable jack detect feature.
514  *
515  * @param handle WM8960 handle structure.
516  * @param isEnabled Enable or disable moudles.
517  */
518 status_t WM8960_SetJackDetect(wm8960_handle_t *handle, bool isEnabled);
519 
520 /*!
521  * @brief Write register to WM8960 using I2C.
522  *
523  * @param handle WM8960 handle structure.
524  * @param reg The register address in WM8960.
525  * @param val Value needs to write into the register.
526  */
527 status_t WM8960_WriteReg(wm8960_handle_t *handle, uint8_t reg, uint16_t val);
528 
529 /*!
530  * @brief Read register from WM8960 using I2C.
531  * @param reg The register address in WM8960.
532  * @param val Value written to.
533  */
534 status_t WM8960_ReadReg(uint8_t reg, uint16_t *val);
535 
536 /*!
537  * @brief Modify some bits in the register using I2C.
538  * @param handle WM8960 handle structure.
539  * @param reg The register address in WM8960.
540  * @param mask The mask code for the bits want to write. The bit you want to write should be 0.
541  * @param val Value needs to write into the register.
542  */
543 status_t WM8960_ModifyReg(wm8960_handle_t *handle, uint8_t reg, uint16_t mask, uint16_t val);
544 
545 #if defined(__cplusplus)
546 }
547 #endif
548 
549 /*! @} */
550 
551 #endif /* _FSL_WM8960_H_ */
552 
553 /*******************************************************************************
554  * API
555  ******************************************************************************/
556