libpynq (release 5EWC0-2023 version 0.2.2 of 2023-09-24 22:22)
Loading...
Searching...
No Matches
audio.h
Go to the documentation of this file.
1#ifndef AUDIO_H
2#define AUDIO_H
3#include <stdint.h>
4
32#define LINE_IN 0
33#define MIC 1
34
35// Slave address for the ADAU audio controller 8
36#define IIC_SLAVE_ADDR 0x3B
37
38// I2C Serial Clock frequency in Hertz
39#define IIC_SCLK_RATE 400000
40
41// I2S Register
42#define I2S_DATA_RX_L_REG 0x00
43#define I2S_DATA_RX_R_REG 0x04
44#define I2S_DATA_TX_L_REG 0x08
45#define I2S_DATA_TX_R_REG 0x0C
46#define I2S_STATUS_REG 0x10
47
48// Audio registers
101 R66_CLOCK_ENABLE_1 = 0xFA
103
109extern void audio_init(void);
110
116extern void audio_select_input(int input);
117
118// Original ADAU1761 code
119
120extern void write_audio_reg(unsigned char u8RegAddr, unsigned char u8Data,
121 int iic_fd);
122
123extern void config_audio_pll(void);
124
125extern void config_audio_codec(void);
126
130extern void select_line_in(void);
131
135extern void select_mic(void);
136
140extern void deselect(void);
141
149extern void audio_bypass(unsigned int audio_mmap_size, unsigned int nsamples,
150 unsigned int volume, int uio_index);
151
164extern void audio_record(unsigned int audio_mmap_size, unsigned int *BufAddr,
165 unsigned int nsamples, int uio_index);
166
167/*
168 * @brief Function to support audio playing without the audio codec controller.
169 *
170 * Notice that the buffer has to be twice the size of the number of samples,
171 * because both left and right channels are sampled.
172 * Consecutive indexes are played synchronisly on left and right output.
173 *
174 * @param audio_mmap_size is the address range of the audio codec.
175 * @param BufAddr is the buffer address.
176 * @param nsamples is the number of samples.
177 * @param uio_index is the uio index in /dev list.
178 * @param volume is the volume of the output.
179 */
180extern void audio_play(unsigned int audio_mmap_size, unsigned int *BufAddr,
181 unsigned int nsamples, unsigned int volume,
182 int uio_index);
183
193extern void audio_repeat_play(unsigned int audio_mmap_size,
194 unsigned int *BufAddr, unsigned int nsamples,
195 unsigned int volume, unsigned int repetitions);
196
197/*
198 * @brief Function to generate a specific tone on the audio output.
199 * @param frequency is the frequency in Hz to be played.
200 * @param time_ms is the time the frequency should be played in ms.
201 * @param volume is the volume of the output.
202 */
203extern void audio_generate_tone(unsigned int frequency, uint32_t time_ms,
204 unsigned int volume);
205
210#endif
void audio_generate_tone(unsigned int frequency, uint32_t time_ms, unsigned int volume)
Definition audio.c:570
void deselect(void)
Function to deselect input, either LINE_IN, or MIC.
Definition audio.c:286
audio_adau1761_regs
Definition audio.h:49
void audio_record(unsigned int audio_mmap_size, unsigned int *BufAddr, unsigned int nsamples, int uio_index)
Function to support audio recording without the audio codec controller.
Definition audio.c:381
void select_mic(void)
Function to select MIC as input.
Definition audio.c:257
void write_audio_reg(unsigned char u8RegAddr, unsigned char u8Data, int iic_fd)
Definition audio.c:90
void audio_repeat_play(unsigned int audio_mmap_size, unsigned int *BufAddr, unsigned int nsamples, unsigned int volume, unsigned int repetitions)
Function to play one audio fragment for multiple repititions.
Definition audio.c:502
void config_audio_codec(void)
Definition audio.c:174
void audio_play(unsigned int audio_mmap_size, unsigned int *BufAddr, unsigned int nsamples, unsigned int volume, int uio_index)
Definition audio.c:430
void audio_bypass(unsigned int audio_mmap_size, unsigned int nsamples, unsigned int volume, int uio_index)
Record and play the audio without storing in DRAM.
Definition audio.c:304
void audio_select_input(int input)
selects the audio input channel.
Definition audio.c:77
void audio_init(void)
Initializes the audio register. Sets the sampling frequency. defines several values such as audio rec...
Definition audio.c:72
void config_audio_pll(void)
Definition audio.c:102
void select_line_in(void)
Function to select LINE_IN as input.
Definition audio.c:234
@ R17_CONVERTER_CONTROL_0
Definition audio.h:67
@ R8_LEFT_DIFFERENTIAL_INPUT_VOLUME_CONTROL
Definition audio.h:58
@ R9_RIGHT_DIFFERENTIAL_INPUT_VOLUME_CONTROL
Definition audio.h:59
@ R36_DAC_CONTROL_0
Definition audio.h:86
@ R29_PLAYBACK_HEADPHONE_LEFT_VOLUME_CONTROL
Definition audio.h:79
@ R41_CONTROL_PORT_PAD_CONTROL_1
Definition audio.h:91
@ R42_JACK_DETECT_PIN_CONTROL
Definition audio.h:92
@ R26_PLAYBACK_LR_MIXER_LEFT_LINE_OUTPUT_CONTROL
Definition audio.h:76
@ R5_RECORD_MIXER_LEFT_CONTROL_1
Definition audio.h:55
@ R67_DEJITTER_CONTROL
Definition audio.h:93
@ R22_PLAYBACK_MIXER_LEFT_CONTROL_0
Definition audio.h:72
@ R39_SERIAL_PORT_PAD_CONTROL
Definition audio.h:89
@ R34_PLAYBACK_POP_CLICK_SUPPRESSION
Definition audio.h:84
@ R18_CONVERTER_CONTROL_1
Definition audio.h:68
@ R6_RECORD_MIXER_RIGHT_CONTROL_0
Definition audio.h:56
@ R35_PLAYBACK_POWER_MANAGEMENT
Definition audio.h:85
@ R30_PLAYBACK_HEADPHONE_RIGHT_VOLUME_CONTROL
Definition audio.h:80
@ R58_SERIAL_INPUT_ROUTE_CONTROL
Definition audio.h:94
@ R27_PLAYBACK_LR_MIXER_RIGHT_LINE_OUTPUT_CONTROL
Definition audio.h:77
@ R0_CLOCK_CONTROL
Definition audio.h:50
@ R1_PLL_CONTROL
Definition audio.h:51
@ R59_SERIAL_OUTPUT_ROUTE_CONTROL
Definition audio.h:95
@ R66_CLOCK_ENABLE_1
Definition audio.h:101
@ R12_ALC_CONTROL_1
Definition audio.h:62
@ R23_PLAYBACK_MIXER_LEFT_CONTROL_1
Definition audio.h:73
@ R7_RECORD_MIXER_RIGHT_CONTROL_1
Definition audio.h:57
@ R13_ALC_CONTROL_2
Definition audio.h:63
@ R37_DAC_CONTROL_1
Definition audio.h:87
@ R19_ADC_CONTROL
Definition audio.h:69
@ R3_RECORD_POWER_MANAGEMENT
Definition audio.h:53
@ R40_CONTROL_PORT_PAD_CONTROL_0
Definition audio.h:90
@ R4_RECORD_MIXER_LEFT_CONTROL_0
Definition audio.h:54
@ R31_PLAYBACK_LINE_OUTPUT_LEFT_VOLUME_CONTROL
Definition audio.h:81
@ R65_CLOCK_ENABLE_0
Definition audio.h:100
@ R21_RIGHT_INPUT_DIGITAL_VOLUME
Definition audio.h:71
@ R38_DAC_CONTROL_2
Definition audio.h:88
@ R32_PLAYBACK_LINE_OUTPUT_RIGHT_VOLUME_CONTROL
Definition audio.h:82
@ R62_DSP_RUN
Definition audio.h:97
@ R24_PLAYBACK_MIXER_RIGHT_CONTROL_0
Definition audio.h:74
@ R61_DSP_ENABLE
Definition audio.h:96
@ R11_ALC_CONTROL_0
Definition audio.h:61
@ R10_RECORD_MICROPHONE_BIAS_CONTROL
Definition audio.h:60
@ R64_SERIAL_PORT_SAMPLING_RATE
Definition audio.h:99
@ R14_ALC_CONTROL_3
Definition audio.h:64
@ R15_SERIAL_PORT_CONTROL_0
Definition audio.h:65
@ R25_PLAYBACK_MIXER_RIGHT_CONTROL_1
Definition audio.h:75
@ R28_PLAYBACK_LR_MIXER_MONO_OUTPUT_CONTROL
Definition audio.h:78
@ R16_SERIAL_PORT_CONTROL_1
Definition audio.h:66
@ R63_DSP_SLEW_MODES
Definition audio.h:98
@ R33_PLAYBACK_MONO_OUTPUT_CONTROL
Definition audio.h:83
@ R2_DIGITAL_MIC_JACK_DETECTION_CONTROL
Definition audio.h:52
@ R20_LEFT_INPUT_DIGITAL_VOLUME
Definition audio.h:70