fsl_codec_common.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017- 2019 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_CODEC_COMMON_H_
10 #define _FSL_CODEC_COMMON_H_
11 
12 #include "fsl_common.h"
13 #include "fsl_codec_adapter.h"
14 
19 /*******************************************************************************
20  * Definitions
21  ******************************************************************************/
25 #define FSL_CODEC_DRIVER_VERSION (MAKE_VERSION(2, 2, 0))
26 
29 #define CODEC_VOLUME_MAX_VALUE (100U)
30 
33 {
40 };
41 
44 {
52 
55 {
68 };
69 
72 {
77 };
78 
80 typedef enum _codec_module
81 {
96 
99 {
102 
105 {
108 };
109 
112 {
118 };
119 
122 {
135 };
136 
139 {
147 };
148 
151 {
167 };
168 
171 {
215 };
216 
219 
221 typedef struct _codec_config
222 {
223  uint32_t codecDevType;
226 
228 typedef struct _codec_capability
229 {
234 
241 {
245 };
246 
247 /*******************************************************************************
248  * API
249  ******************************************************************************/
250 
251 #if defined(__cplusplus)
252 extern "C" {
253 #endif
254 
262 
270 
280 status_t CODEC_SetFormat(codec_handle_t *handle, uint32_t mclk, uint32_t sampleRate, uint32_t bitWidth);
281 
296 
305 status_t CODEC_SetVolume(codec_handle_t *handle, uint32_t channel, uint32_t volume);
306 
315 status_t CODEC_SetMute(codec_handle_t *handle, uint32_t channel, bool mute);
316 
325 status_t CODEC_SetPower(codec_handle_t *handle, codec_module_t module, bool powerOn);
326 
335 status_t CODEC_SetRecord(codec_handle_t *handle, uint32_t recordRource);
336 
348 status_t CODEC_SetRecordChannel(codec_handle_t *handle, uint32_t leftRecordChannel, uint32_t rightRecordChannel);
349 
358 status_t CODEC_SetPlay(codec_handle_t *handle, uint32_t playSource);
359 
360 #if defined(__cplusplus)
361 }
362 #endif
363 
365 #endif /* _FSL_CODEC_COMMON_H_ */
kCODEC_PlayChannelHeadphoneLeft
@ kCODEC_PlayChannelHeadphoneLeft
Definition: fsl_codec_common.h:152
fsl_common.h
kCODEC_SupportModuleDAC
@ kCODEC_SupportModuleDAC
Definition: fsl_codec_common.h:173
kCODEC_RecordChannelLeft1
@ kCODEC_RecordChannelLeft1
Definition: fsl_codec_common.h:123
kCODEC_ModuleMxier
@ kCODEC_ModuleMxier
Definition: fsl_codec_common.h:94
_codec_config::codecDevConfig
void * codecDevConfig
Definition: fsl_codec_common.h:224
codec_audio_protocol_t
enum _codec_audio_protocol codec_audio_protocol_t
AUDIO format definition.
kCODEC_SupportRecordChannelRight1
@ kCODEC_SupportRecordChannelRight1
Definition: fsl_codec_common.h:212
kStatusGroup_CODEC
@ kStatusGroup_CODEC
Definition: fsl_common.h:167
kCODEC_SupportModuleVref
@ kCODEC_SupportModuleVref
Definition: fsl_codec_common.h:179
kCODEC_AudioSampleRate16KHz
@ kCODEC_AudioSampleRate16KHz
Definition: fsl_codec_common.h:59
kCODEC_PlayChannelLineOutRight
@ kCODEC_PlayChannelLineOutRight
Definition: fsl_codec_common.h:157
kCODEC_SupportPlaySourceMixerIn
@ kCODEC_SupportPlaySourceMixerIn
Definition: fsl_codec_common.h:199
kCODEC_ModuleHeadphone
@ kCODEC_ModuleHeadphone
Definition: fsl_codec_common.h:85
kCODEC_BusI2S
@ kCODEC_BusI2S
Definition: fsl_codec_common.h:45
kCODEC_RecordChannelLeft2
@ kCODEC_RecordChannelLeft2
Definition: fsl_codec_common.h:124
kCODEC_SupportRecordSourceDifferentialMic
@ kCODEC_SupportRecordSourceDifferentialMic
Definition: fsl_codec_common.h:206
_codec_config
Initialize structure of the codec.
Definition: fsl_codec_common.h:221
kCODEC_SupportModuleMixer
@ kCODEC_SupportModuleMixer
Definition: fsl_codec_common.h:184
kCODEC_SupportPlaySourceInput
@ kCODEC_SupportPlaySourceInput
Definition: fsl_codec_common.h:197
_codec_capability::codecPlayCapability
uint32_t codecPlayCapability
Definition: fsl_codec_common.h:231
kCODEC_PlayChannelLineOutLeft
@ kCODEC_PlayChannelLineOutLeft
Definition: fsl_codec_common.h:156
kCODEC_ModulePGA
@ kCODEC_ModulePGA
Definition: fsl_codec_common.h:84
_codec_play_source
_codec_play_source
audio codec module play source value
Definition: fsl_codec_common.h:138
kCODEC_SupportModuleHeadphone
@ kCODEC_SupportModuleHeadphone
Definition: fsl_codec_common.h:175
kCODEC_AudioBitWidth20bit
@ kCODEC_AudioBitWidth20bit
Definition: fsl_codec_common.h:74
kCODEC_SupportRecordChannelLeft3
@ kCODEC_SupportRecordChannelLeft3
Definition: fsl_codec_common.h:211
kCODEC_SupportModuleI2SIn
@ kCODEC_SupportModuleI2SIn
Definition: fsl_codec_common.h:182
_codec_handle::codecConfig
codec_config_t * codecConfig
Definition: fsl_codec_common.h:242
kCODEC_SupportModuleADC
@ kCODEC_SupportModuleADC
Definition: fsl_codec_common.h:172
codec_module_ctrl_cmd_t
enum _codec_module_ctrl_cmd codec_module_ctrl_cmd_t
audio codec module control cmd
kCODEC_PlaySourceInput
@ kCODEC_PlaySourceInput
Definition: fsl_codec_common.h:141
kCODEC_ModuleMic
@ kCODEC_ModuleMic
Definition: fsl_codec_common.h:91
_codec_module
_codec_module
audio codec module
Definition: fsl_codec_common.h:80
kCODEC_PlaySourceMixerIn
@ kCODEC_PlaySourceMixerIn
Definition: fsl_codec_common.h:143
kCODEC_SupportModulePGA
@ kCODEC_SupportModulePGA
Definition: fsl_codec_common.h:174
kCODEC_ModuleSwitchI2SInInterface
@ kCODEC_ModuleSwitchI2SInInterface
Definition: fsl_codec_common.h:100
kCODEC_RecordChannelRight2
@ kCODEC_RecordChannelRight2
Definition: fsl_codec_common.h:127
_codec_module_ctrl_cmd
_codec_module_ctrl_cmd
audio codec module control cmd
Definition: fsl_codec_common.h:98
_codec_audio_protocol
_codec_audio_protocol
AUDIO format definition.
Definition: fsl_codec_common.h:43
CODEC_SetFormat
status_t CODEC_SetFormat(codec_handle_t *handle, uint32_t mclk, uint32_t sampleRate, uint32_t bitWidth)
set audio data format.
Definition: fsl_codec_common.c:64
kCODEC_AudioSampleRate32KHz
@ kCODEC_AudioSampleRate32KHz
Definition: fsl_codec_common.h:62
kCODEC_ModuleSpeaker
@ kCODEC_ModuleSpeaker
Definition: fsl_codec_common.h:86
kCODEC_PlayChannelLeft2
@ kCODEC_PlayChannelLeft2
Definition: fsl_codec_common.h:163
kCODEC_PlayChannelLeft0
@ kCODEC_PlayChannelLeft0
Definition: fsl_codec_common.h:159
kCODEC_AudioSampleRate192KHz
@ kCODEC_AudioSampleRate192KHz
Definition: fsl_codec_common.h:66
kCODEC_SupportModuleI2SInSwitchInterface
@ kCODEC_SupportModuleI2SInSwitchInterface
Definition: fsl_codec_common.h:185
kCODEC_SupportPlaySourceAux
@ kCODEC_SupportPlaySourceAux
Definition: fsl_codec_common.h:202
kCODEC_SupportModuleMicbias
@ kCODEC_SupportModuleMicbias
Definition: fsl_codec_common.h:180
kCODEC_SupportRecordChannelLeft2
@ kCODEC_SupportRecordChannelLeft2
Definition: fsl_codec_common.h:210
kCODEC_ModuleADC
@ kCODEC_ModuleADC
Definition: fsl_codec_common.h:82
kCODEC_PlayChannelLeft3
@ kCODEC_PlayChannelLeft3
Definition: fsl_codec_common.h:165
kCODEC_RecordChannelRight1
@ kCODEC_RecordChannelRight1
Definition: fsl_codec_common.h:126
kCODEC_SupportRecordChannelLeft1
@ kCODEC_SupportRecordChannelLeft1
Definition: fsl_codec_common.h:209
_codec_module_ctrl_i2s_in_interface
_codec_module_ctrl_i2s_in_interface
audio codec module digital interface
Definition: fsl_codec_common.h:104
CODEC_Init
status_t CODEC_Init(codec_handle_t *handle, codec_config_t *config)
Codec initilization.
Definition: fsl_codec_common.c:32
kCODEC_SupportModuleMic
@ kCODEC_SupportModuleMic
Definition: fsl_codec_common.h:181
kCODEC_PlayChannelRight1
@ kCODEC_PlayChannelRight1
Definition: fsl_codec_common.h:162
kCODEC_BusPCMA
@ kCODEC_BusPCMA
Definition: fsl_codec_common.h:48
kCODEC_SupportPlayChannelRight1
@ kCODEC_SupportPlayChannelRight1
Definition: fsl_codec_common.h:190
kStatus_CODEC_I2CBusInitialFailed
@ kStatus_CODEC_I2CBusInitialFailed
Definition: fsl_codec_common.h:36
kCODEC_SupportRecordChannelRight2
@ kCODEC_SupportRecordChannelRight2
Definition: fsl_codec_common.h:213
kCODEC_AudioSampleRate384KHz
@ kCODEC_AudioSampleRate384KHz
Definition: fsl_codec_common.h:67
kCODEC_PlayChannelRight3
@ kCODEC_PlayChannelRight3
Definition: fsl_codec_common.h:166
kStatus_CODEC_I2CCommandTransferFailed
@ kStatus_CODEC_I2CCommandTransferFailed
Definition: fsl_codec_common.h:38
kCODEC_ModuleI2SInInterfacePCM
@ kCODEC_ModuleI2SInInterfacePCM
Definition: fsl_codec_common.h:106
kCODEC_RecordChannelDifferentialPositive1
@ kCODEC_RecordChannelDifferentialPositive1
Definition: fsl_codec_common.h:129
kCODEC_ModuleLineout
@ kCODEC_ModuleLineout
Definition: fsl_codec_common.h:88
kCODEC_SupportPlayChannelLeft2
@ kCODEC_SupportPlayChannelLeft2
Definition: fsl_codec_common.h:191
kCODEC_SupportPlaySourcePGA
@ kCODEC_SupportPlaySourcePGA
Definition: fsl_codec_common.h:196
CODEC_SetRecordChannel
status_t CODEC_SetRecordChannel(codec_handle_t *handle, uint32_t leftRecordChannel, uint32_t rightRecordChannel)
codec set record channel.
Definition: fsl_codec_common.c:205
MAKE_STATUS
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:43
kCODEC_SupportRecordSourceSingleEndMic
@ kCODEC_SupportRecordSourceSingleEndMic
Definition: fsl_codec_common.h:208
kCODEC_SupportRecordSourceLineInput
@ kCODEC_SupportRecordSourceLineInput
Definition: fsl_codec_common.h:205
kCODEC_SupportPlayChannelRight0
@ kCODEC_SupportPlayChannelRight0
Definition: fsl_codec_common.h:188
kCODEC_ModuleI2SOut
@ kCODEC_ModuleI2SOut
Definition: fsl_codec_common.h:93
kCODEC_SupportPlayChannelRight3
@ kCODEC_SupportPlayChannelRight3
Definition: fsl_codec_common.h:194
CODEC_ModuleControl
status_t CODEC_ModuleControl(codec_handle_t *handle, codec_module_ctrl_cmd_t cmd, uint32_t data)
codec module control.
Definition: fsl_codec_common.c:84
_codec_reocrd_channel
_codec_reocrd_channel
audio codec record channel
Definition: fsl_codec_common.h:121
_codec_handle::codecCapability
const codec_capability_t * codecCapability
Definition: fsl_codec_common.h:243
kCODEC_PlaySourceAux
@ kCODEC_PlaySourceAux
Definition: fsl_codec_common.h:146
_codec_status
_codec_status
CODEC status.
Definition: fsl_codec_common.h:32
kCODEC_BusPCMB
@ kCODEC_BusPCMB
Definition: fsl_codec_common.h:49
kCODEC_RecordChannelDifferentialNegative3
@ kCODEC_RecordChannelDifferentialNegative3
Definition: fsl_codec_common.h:134
kStatus_CODEC_NotSupport
@ kStatus_CODEC_NotSupport
Definition: fsl_codec_common.h:34
codec_module_t
enum _codec_module codec_module_t
audio codec module
kCODEC_PlayChannelRight2
@ kCODEC_PlayChannelRight2
Definition: fsl_codec_common.h:164
kCODEC_AudioSampleRate11025Hz
@ kCODEC_AudioSampleRate11025Hz
Definition: fsl_codec_common.h:57
kCODEC_ModuleMicbias
@ kCODEC_ModuleMicbias
Definition: fsl_codec_common.h:90
kCODEC_ModuleI2SInInterfaceDSD
@ kCODEC_ModuleI2SInInterfaceDSD
Definition: fsl_codec_common.h:107
CODEC_SetRecord
status_t CODEC_SetRecord(codec_handle_t *handle, uint32_t recordRource)
codec set record source.
Definition: fsl_codec_common.c:180
kCODEC_SupportPlaySourceDAC
@ kCODEC_SupportPlaySourceDAC
Definition: fsl_codec_common.h:198
kCODEC_BusLeftJustified
@ kCODEC_BusLeftJustified
Definition: fsl_codec_common.h:46
kCODEC_RecordChannelDifferentialPositive2
@ kCODEC_RecordChannelDifferentialPositive2
Definition: fsl_codec_common.h:130
kCODEC_AudioSampleRate8KHz
@ kCODEC_AudioSampleRate8KHz
Definition: fsl_codec_common.h:56
kCODEC_PlayChannelSpeakerLeft
@ kCODEC_PlayChannelSpeakerLeft
Definition: fsl_codec_common.h:154
kCODEC_AudioSampleRate96KHz
@ kCODEC_AudioSampleRate96KHz
Definition: fsl_codec_common.h:65
CODEC_Deinit
status_t CODEC_Deinit(codec_handle_t *handle)
Codec de-initilization.
Definition: fsl_codec_common.c:48
kCODEC_SupportPlayChannelLeft1
@ kCODEC_SupportPlayChannelLeft1
Definition: fsl_codec_common.h:189
kCODEC_SupportModuleSpeaker
@ kCODEC_SupportModuleSpeaker
Definition: fsl_codec_common.h:176
kCODEC_AudioSampleRate12KHz
@ kCODEC_AudioSampleRate12KHz
Definition: fsl_codec_common.h:58
codec_capability_t
struct _codec_capability codec_capability_t
codec capability
kCODEC_RecordChannelDifferentialNegative2
@ kCODEC_RecordChannelDifferentialNegative2
Definition: fsl_codec_common.h:133
kCODEC_PlayChannelHeadphoneRight
@ kCODEC_PlayChannelHeadphoneRight
Definition: fsl_codec_common.h:153
kCODEC_ModuleI2SIn
@ kCODEC_ModuleI2SIn
Definition: fsl_codec_common.h:92
kCODEC_PlayChannelLeft1
@ kCODEC_PlayChannelLeft1
Definition: fsl_codec_common.h:161
kCODEC_SupportPlayChannelLeft3
@ kCODEC_SupportPlayChannelLeft3
Definition: fsl_codec_common.h:193
_codec_capability
codec capability
Definition: fsl_codec_common.h:228
_codec_audio_sample_rate
_codec_audio_sample_rate
audio sample rate definition
Definition: fsl_codec_common.h:54
kCODEC_SupportRecordSourceDigitalMic
@ kCODEC_SupportRecordSourceDigitalMic
Definition: fsl_codec_common.h:207
_codec_play_channel
_codec_play_channel
codec play channel
Definition: fsl_codec_common.h:150
CODEC_SetMute
status_t CODEC_SetMute(codec_handle_t *handle, uint32_t channel, bool mute)
set audio codec module mute.
Definition: fsl_codec_common.c:136
kCODEC_SupportRecordSourceDifferentialLine
@ kCODEC_SupportRecordSourceDifferentialLine
Definition: fsl_codec_common.h:204
kCODEC_PlayChannelSpeakerRight
@ kCODEC_PlayChannelSpeakerRight
Definition: fsl_codec_common.h:155
kCODEC_AudioSampleRate48KHz
@ kCODEC_AudioSampleRate48KHz
Definition: fsl_codec_common.h:64
kCODEC_SupportRecordChannelRight3
@ kCODEC_SupportRecordChannelRight3
Definition: fsl_codec_common.h:214
kCODEC_AudioSampleRate44100Hz
@ kCODEC_AudioSampleRate44100Hz
Definition: fsl_codec_common.h:63
HAL_CODEC_HANDLER_SIZE
#define HAL_CODEC_HANDLER_SIZE
codec handler size
Definition: fsl_codec_adapter.h:22
kCODEC_RecordSourceDifferentialMic
@ kCODEC_RecordSourceDifferentialMic
Definition: fsl_codec_common.h:115
kCODEC_PlaySourcePGA
@ kCODEC_PlaySourcePGA
Definition: fsl_codec_common.h:140
kCODEC_BusRightJustified
@ kCODEC_BusRightJustified
Definition: fsl_codec_common.h:47
kCODEC_SupportPlaySourceMixerInRight
@ kCODEC_SupportPlaySourceMixerInRight
Definition: fsl_codec_common.h:201
_codec_audio_bit_width
_codec_audio_bit_width
audio bit width
Definition: fsl_codec_common.h:71
kCODEC_SupportModuleLinein
@ kCODEC_SupportModuleLinein
Definition: fsl_codec_common.h:177
kCODEC_SupportPlayChannelRight2
@ kCODEC_SupportPlayChannelRight2
Definition: fsl_codec_common.h:192
kCODEC_PlaySourceMixerInRight
@ kCODEC_PlaySourceMixerInRight
Definition: fsl_codec_common.h:145
kCODEC_RecordChannelLeft3
@ kCODEC_RecordChannelLeft3
Definition: fsl_codec_common.h:125
kCODEC_ModuleLinein
@ kCODEC_ModuleLinein
Definition: fsl_codec_common.h:87
fsl_codec_adapter.h
kCODEC_AudioBitWidth24bit
@ kCODEC_AudioBitWidth24bit
Definition: fsl_codec_common.h:75
kCODEC_PlayChannelRight0
@ kCODEC_PlayChannelRight0
Definition: fsl_codec_common.h:160
_codec_handle::codecDevHandle
uint8_t codecDevHandle[HAL_CODEC_HANDLER_SIZE]
Definition: fsl_codec_common.h:244
kCODEC_ModuleVref
@ kCODEC_ModuleVref
Definition: fsl_codec_common.h:89
kCODEC_SupportModuleLineout
@ kCODEC_SupportModuleLineout
Definition: fsl_codec_common.h:178
CODEC_SetPlay
status_t CODEC_SetPlay(codec_handle_t *handle, uint32_t playSource)
codec set play source.
Definition: fsl_codec_common.c:232
_codec_capability::codecRecordCapability
uint32_t codecRecordCapability
Definition: fsl_codec_common.h:232
_codec_record_source
_codec_record_source
audio codec module record source value
Definition: fsl_codec_common.h:111
codec_config_t
struct _codec_config codec_config_t
Initialize structure of the codec.
kCODEC_RecordChannelRight3
@ kCODEC_RecordChannelRight3
Definition: fsl_codec_common.h:128
kCODEC_RecordChannelDifferentialNegative1
@ kCODEC_RecordChannelDifferentialNegative1
Definition: fsl_codec_common.h:132
kCODEC_SupportPlaySourceMixerInLeft
@ kCODEC_SupportPlaySourceMixerInLeft
Definition: fsl_codec_common.h:200
kCODEC_RecordSourceLineInput
@ kCODEC_RecordSourceLineInput
Definition: fsl_codec_common.h:114
kCODEC_PlaySourceDAC
@ kCODEC_PlaySourceDAC
Definition: fsl_codec_common.h:142
kCODEC_AudioSampleRate22050Hz
@ kCODEC_AudioSampleRate22050Hz
Definition: fsl_codec_common.h:60
_codec_capability_flag
_codec_capability_flag
audio codec capability
Definition: fsl_codec_common.h:170
config
static sai_transceiver_t config
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:75
kCODEC_AudioBitWidth32bit
@ kCODEC_AudioBitWidth32bit
Definition: fsl_codec_common.h:76
kCODEC_SupportModuleI2SOut
@ kCODEC_SupportModuleI2SOut
Definition: fsl_codec_common.h:183
kCODEC_RecordSourceDifferentialLine
@ kCODEC_RecordSourceDifferentialLine
Definition: fsl_codec_common.h:113
kCODEC_PlaySourceMixerInLeft
@ kCODEC_PlaySourceMixerInLeft
Definition: fsl_codec_common.h:144
cmd
string cmd
kCODEC_ModuleDAC
@ kCODEC_ModuleDAC
Definition: fsl_codec_common.h:83
CODEC_SetPower
status_t CODEC_SetPower(codec_handle_t *handle, codec_module_t module, bool powerOn)
set audio codec power.
Definition: fsl_codec_common.c:158
status_t
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:189
kStatus_CODEC_DeviceNotRegistered
@ kStatus_CODEC_DeviceNotRegistered
Definition: fsl_codec_common.h:35
kCODEC_BusTDM
@ kCODEC_BusTDM
Definition: fsl_codec_common.h:50
kCODEC_SupportPlayChannelLeft0
@ kCODEC_SupportPlayChannelLeft0
Definition: fsl_codec_common.h:187
_codec_config::codecDevType
uint32_t codecDevType
Definition: fsl_codec_common.h:223
kCODEC_AudioSampleRate24KHz
@ kCODEC_AudioSampleRate24KHz
Definition: fsl_codec_common.h:61
CODEC_SetVolume
status_t CODEC_SetVolume(codec_handle_t *handle, uint32_t channel, uint32_t volume)
set audio codec pl volume.
Definition: fsl_codec_common.c:113
kCODEC_RecordSourceDigitalMic
@ kCODEC_RecordSourceDigitalMic
Definition: fsl_codec_common.h:116
kCODEC_RecordSourceSingleEndMic
@ kCODEC_RecordSourceSingleEndMic
Definition: fsl_codec_common.h:117
_codec_handle
Codec handle definition.
Definition: fsl_codec_common.h:240
_codec_capability::codecModuleCapability
uint32_t codecModuleCapability
Definition: fsl_codec_common.h:230
kCODEC_AudioBitWidth16bit
@ kCODEC_AudioBitWidth16bit
Definition: fsl_codec_common.h:73
kCODEC_RecordChannelDifferentialPositive3
@ kCODEC_RecordChannelDifferentialPositive3
Definition: fsl_codec_common.h:131


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56