Skip to content
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

Some improvement to adc_continuous and i2s_common (IDFGH-11855) #12944

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mcapdeville
Copy link
Contributor

Hi,
This is somme proposed little improvement to adc and i2s driver.

  • In adc continuous driver, it(s not always a good idea to use ringbuffer. to avoid unnecessary copying of data. The first patch allow disabling ringbuff by setting max_store_buf_sieze member of adc_continuous_handle_cfg_t structure to 0.

  • The second patch resolve some rounding problem in adc_hal_digi_sample_freq_config

  • The third patch is for

    • clearing i2s transmit dma buffer before calling on_sent callback
    • directly setting the dma buffer address in event.data of callbacks instead of that of the finish_desc->buf member

Marc

@CLAassistant
Copy link

CLAassistant commented Jan 7, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

github-actions bot commented Jan 7, 2024

Warnings
⚠️ Please consider squashing your 8 commits (simplifying branch history).

👋 Hello mcapdeville, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by 🚫 dangerJS against c0c6921

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 7, 2024
@github-actions github-actions bot changed the title Some improvement to adc_continuous and i2s_common Some improvement to adc_continuous and i2s_common (IDFGH-11855) Jan 7, 2024
@@ -10,6 +10,7 @@
#include "hal/assert.h"
#include "soc/lldesc.h"
#include "soc/soc_caps.h"
#include "esp_log.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't allow to use "esp_log.h" in the hal component, instead, we suggest using "hal/log.h" in the hal.

@L-KAYA
Copy link
Collaborator

L-KAYA commented Feb 19, 2024

Hi @mcapdeville , thanks for your contribution! I have one question, why we should clear the i2s tx buffer before callback? Some use cases would like to read back these sent data to check the data latency, clearing before callback will break these cases.

Another concern is that the pointer change of event.data might lead to breaking change, do you think this change is critical?

@mcapdeville
Copy link
Contributor Author

Hi,

Hi @mcapdeville , thanks for your contribution! I have one question, why we should clear the i2s tx buffer before callback? Some use cases would like to read back these sent data to check the data latency, clearing before callback will break these cases.

In my application, I directly fill dma buffers in the callback function. I 'm trying to avoid unnecessary recopy of data by passing the buffer's pointer to the encoding function. If ther is no data to be sent, the output datas are allready zeroed.

  • Zeroing the buffer after the callback will erase the encoded datas.
  • The i2s_channel_write function add an unnecessary copy of data.

Another concern is that the pointer change of event.data might lead to breaking change, do you think this change is critical?

I think, it is more practical the the event struct contain the pointer to the dma buffer and size of the buffer instead of a pointer on the pointer to the dma buffer.

Regards.


Marc

@songruo songruo added the PR-Sync-Merge Pull request sync as merge commit label Feb 20, 2024
@espressif espressif deleted a comment from L-KAYA Feb 22, 2024
@suda-morris suda-morris removed the PR-Sync-Merge Pull request sync as merge commit label Feb 22, 2024
@suda-morris
Copy link
Collaborator

sha=5e6a1e5aee8a446670f291d048ae24abf491f456

@suda-morris suda-morris added the PR-Sync-Merge Pull request sync as merge commit label Feb 22, 2024
@L-KAYA
Copy link
Collaborator

L-KAYA commented Feb 22, 2024

Hi @mcapdeville, the sequence of buffer clear and callback may need more discussion.

If you want to copy data into the TX DMA buffer directly in the callback, you can just disable the auto_clear and operate the buffer in the on_sent callback. Or do you have any reason that auto_clear must be set?

And if the auto_clear first is necessary, do you think it's reasonable to have another flag to decide to execute auto_clear first or on_sent callback first?

As for the DMA buffer, indeed the first level pointer would be more practical, this should be worth a breaking change

@masterxq
Copy link

masterxq commented May 18, 2024

Just a user story:
I have very likely changes in my espressif, and I'm patching them in my pipelines into the espressif framework to avoid extra copy in i2s... This is so unnecessary... I understand why this can be needed, but I really don't understand why this is the only possible way, it is just super ugly :/

In my implementation I have an additional function that's avoid copying and the Original is unpatches...

This could be a way around possible breaking changes, find problems, learn more user stories and avoid that users needs to implement it again and again...

@mcapdeville mcapdeville force-pushed the mcapdeville branch 3 times, most recently from 722c306 to 3dc4aad Compare December 26, 2024 19:40
    Whithout this patch, compilling for ESP32s3 with power management
    enabled lead to a 'dangerous relocation error' in sleep_modes.c at
    esp_wake_stub_entry function.

    Normally, literals variable are embeded just before the entry point
of
    the function, but esp_wake_stub_entry is at start of rtc_ram. So add
a
    jump over at the start of the function, and place the literals
before
    code.
It seams that hal_utils_calc_clk_div_frac_accurate() do not get as accurate
sampling frequency as the hal_utils_calc_clk_div_frac_fast().
This is needed if you want accurate non standard sampling frequencies
(ex : 52800Hz)
This configuration option is added to desactivate work around for PDM TX
clock on V2 HW.

If you needed accurate sampling frequencies, say no.
Add I2S_CLK_SRC_PLL_D2 = SOC_MOD_CLK_PLL_D2 clock source to i2s driver.
Whith this, you could specify a zero size ringbuffer in
adc_continuous_handle_cfg_t.max_store_buffer_size.

This is useful for direct dma buffer access to avoid useless recopy of data.
This is to achieve good rounded clock value.
Add a configuration option to set the number of DMA buffers used by
adc_continuous driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Sync-Merge Pull request sync as merge commit Status: Opened Issue is new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants