1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2020-07-02     thread-liu   first version
9  */
10 
11 #ifndef __DRV_WM8994_H__
12 #define __DRV_WM8994_H__
13 
14 #include "board.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 enum{
21     GET_ID,
22     SET_FREQUENCE,
23     SET_VOLUME,
24     GET_VOLUME,
25     SET_MUTE,
26     SET_RESET,
27     START_PLAY,
28     SET_PLAY_TYPE,
29 };
30 
31 /* codec device play type */
32 #define DEVICE_NONE                           ((uint16_t)0x0000)
33 #define OUTPUT_DEVICE_SPEAKER                 ((uint16_t)0x0001)
34 #define OUTPUT_DEVICE_HEADPHONE               ((uint16_t)0x0002)
35 #define OUTPUT_DEVICE_BOTH                    ((uint16_t)0x0004)
36 #define OUTPUT_DEVICE_AUTO                    ((uint16_t)0x0008)
37 #define INPUT_DEVICE_DIGITAL_MICROPHONE_1     ((uint16_t)0x0010)
38 #define INPUT_DEVICE_DIGITAL_MICROPHONE_2     ((uint16_t)0x0020)
39 #define INPUT_DEVICE_INPUT_LINE_1             ((uint16_t)0x0040)
40 #define INPUT_DEVICE_INPUT_LINE_2             ((uint16_t)0x0080)
41 #define INPUT_DEVICE_DIGITAL_MIC1_MIC2        ((uint16_t)0x0100)
42 
43 /* volume levels values */
44 #define DEFAULT_VOLMIN                0x00
45 #define DEFAULT_VOLMAX                0xFF
46 #define DEFAULT_VOLSTEP               0x04
47 
48 #define AUDIO_PAUSE                   0
49 #define AUDIO_RESUME                  1
50 
51 /* Codec POWER DOWN modes */
52 #define CODEC_PDWN_HW                 1
53 #define CODEC_PDWN_SW                 2
54 
55 /* MUTE commands */
56 #define AUDIO_MUTE_ON                 1
57 #define AUDIO_MUTE_OFF                0
58 
59 /* AUDIO FREQUENCY */
60 #define AUDIO_FREQUENCY_192K          ((uint32_t)192000)
61 #define AUDIO_FREQUENCY_96K           ((uint32_t)96000)
62 #define AUDIO_FREQUENCY_48K           ((uint32_t)48000)
63 #define AUDIO_FREQUENCY_44K           ((uint32_t)44100)
64 #define AUDIO_FREQUENCY_32K           ((uint32_t)32000)
65 #define AUDIO_FREQUENCY_22K           ((uint32_t)22050)
66 #define AUDIO_FREQUENCY_16K           ((uint32_t)16000)
67 #define AUDIO_FREQUENCY_11K           ((uint32_t)11025)
68 #define AUDIO_FREQUENCY_8K            ((uint32_t)8000)
69 
70 #define VOLUME_CONVERT(Volume)        (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100)))
71 #define VOLUME_IN_CONVERT(Volume)     (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100)))
72 
73 #define WM8994_ID                          0x8994
74 #define WM8994_CHIPID_ADDR                 0x00
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
81