-
Notifications
You must be signed in to change notification settings - Fork 0
Add ES7210 digital microphone support #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: cores3_es7210
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
drivers/audio/dmic_es7210.c
Outdated
codec_cfg.dai_route = AUDIO_ROUTE_CAPTURE; | ||
codec_cfg.dai_type = AUDIO_DAI_TYPE_I2S; | ||
codec_cfg.dai_cfg.i2s.word_size = stream->pcm_width; | ||
codec_cfg.dai_cfg.i2s.channels = cfg->channel.req_num_chan; | ||
codec_cfg.dai_cfg.i2s.format = format; | ||
codec_cfg.dai_cfg.i2s.options = conf->i2s_options; | ||
codec_cfg.dai_cfg.i2s.frame_clk_freq = stream->pcm_rate; | ||
codec_cfg.dai_cfg.i2s.mem_slab = stream->mem_slab; | ||
codec_cfg.dai_cfg.i2s.block_size = stream->block_size; | ||
codec_cfg.dai_cfg.i2s.timeout = conf->timeout_ms; | ||
|
||
ret = audio_codec_configure(conf->codec_dev, &codec_cfg); | ||
if (ret < 0) { | ||
LOG_ERR("Failed to configure ES7210 codec (%d)", ret); | ||
return ret; | ||
} | ||
|
||
audio_codec_stop_output(conf->codec_dev); | ||
|
||
i2s_cfg.word_size = stream->pcm_width; | ||
i2s_cfg.channels = cfg->channel.req_num_chan; | ||
i2s_cfg.format = format; | ||
i2s_cfg.options = conf->i2s_options; | ||
i2s_cfg.frame_clk_freq = stream->pcm_rate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configure codec with inverted I²S master/slave role
The DMIC driver derives i2s_options
from the devicetree properties and then applies the same flags to both the I²S controller and the ES7210 codec (codec_cfg.dai_cfg.i2s.options = conf->i2s_options;
and later i2s_cfg.options = conf->i2s_options
). However ES7210_DMIC_OPTIONS()
produces settings from the SoC perspective: when the ES7210 is the bit/frame clock master, the macro returns _SLAVE
so that the I²S peripheral behaves as a slave, and vice versa. Reusing those flags for the codec therefore programs the codec with the opposite master/slave role advertised in devicetree (e.g. the codec is set as master when the SoC should be master). On real hardware this results in both sides trying to act as the same bus role and the microphone never streams. The codec options need to mirror the devicetree properties while the I²S controller should receive the inverted options.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68e12ab37bf48322a10ef69cfb30384a