Repository navigation
Fix Bug:Amp: eliminat pops when switch device between speaker and headphone. #7048
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -598,19 +598,19 @@ static int smart_amp_copy(struct comp_dev *dev) | |
| avail_feedback_frames = | ||
| audio_stream_get_avail_frames(&feedback_buf->stream); | ||
|
|
||
| avail_frames = MIN(avail_passthrough_frames, | ||
| avail_feedback_frames); | ||
| avail_feedback_frames = MIN(avail_passthrough_frames, | ||
| avail_feedback_frames); | ||
|
|
||
| feedback_bytes = avail_frames * | ||
| feedback_bytes = avail_feedback_frames * | ||
| audio_stream_frame_bytes(&feedback_buf->stream); | ||
|
|
||
| comp_dbg(dev, "smart_amp_copy(): processing %d feedback frames (avail_passthrough_frames: %d)", | ||
| avail_frames, avail_passthrough_frames); | ||
| avail_feedback_frames, avail_passthrough_frames); | ||
|
|
||
| /* perform buffer writeback after source_buf process */ | ||
| buffer_stream_invalidate(feedback_buf, feedback_bytes); | ||
| sad->process(dev, &feedback_buf->stream, | ||
| &sink_buf->stream, avail_frames, | ||
| &sink_buf->stream, avail_feedback_frames, | ||
| sad->config.feedback_ch_map, true); | ||
|
|
||
| comp_update_buffer_consume(feedback_buf, feedback_bytes); | ||
|
|
@@ -621,7 +621,6 @@ static int smart_amp_copy(struct comp_dev *dev) | |
|
|
||
| /* bytes calculation */ | ||
| source_bytes = avail_frames * audio_stream_frame_bytes(&source_buf->stream); | ||
|
|
||
| sink_bytes = avail_frames * audio_stream_frame_bytes(&sink_buf->stream); | ||
|
|
||
| /* process data */ | ||
|
|
@@ -727,20 +726,18 @@ static int smart_amp_prepare(struct comp_dev *dev) | |
| goto error; | ||
| } | ||
|
|
||
| if (sad->mod_handle->bitwidth != bitwidth) { | ||
| sad->mod_handle->bitwidth = bitwidth; | ||
| comp_info(dev, "[DSM] Re-initialized for %d bit processing", bitwidth); | ||
| sad->mod_handle->bitwidth = bitwidth; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess there is no performance impact to doing this every time. |
||
| comp_info(dev, "[DSM] Re-initialized for %d bit processing", bitwidth); | ||
|
|
||
| ret = smart_amp_init(sad->mod_handle, dev); | ||
| if (ret) { | ||
| comp_err(dev, "[DSM] Re-initialization error."); | ||
| goto error; | ||
| } | ||
| ret = maxim_dsm_restore_param(sad->mod_handle, dev); | ||
| if (ret) { | ||
| comp_err(dev, "[DSM] Restoration error."); | ||
| goto error; | ||
| } | ||
| ret = smart_amp_init(sad->mod_handle, dev); | ||
| if (ret) { | ||
| comp_err(dev, "[DSM] Re-initialization error."); | ||
| goto error; | ||
| } | ||
| ret = maxim_dsm_restore_param(sad->mod_handle, dev); | ||
| if (ret) { | ||
| comp_err(dev, "[DSM] Restoration error."); | ||
| goto error; | ||
| } | ||
|
|
||
| sad->process = get_smart_amp_process(dev); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Some style and other minor issues, can you address the checkpatch findings in https://github.com/thesofproject/sof/actions/runs/4112079634/jobs/7099324790
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.
There are two pops caused by SOF Firmware.@LongWang100 thanks for the patch, are you saying this bug is present in general SOF FW code or just specific to the smart AMP logic which you have fixed ?
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.
@lgirdwood that's a good question.
It's difficult to tell. However during previous investigation we used to adopt smart_amp_test (SAMPLE_SMART_AMP=y) to run on ADL-P max98373 device, the pop noise was still able to be reproduced. Nevertheless, we had never met the pop noise issue on TGL max98373 devices.
Another thing which had confused me for a long time is that
smart_amp.csounds like to play as the role of common adapter code implementation while there existssmart_amp_maxim_dsm.candsmart_amp_generic.cfor Maxim DSM and generic solution respectively. However, I then realized thatsmart_amp.cbasically serves Maxim DSM only according that UUID is directly defined as Maxim DSM. Also, the initial author ofsmart_amp.cis from Maxim.I wonder if we would expect smart_amp to be a generic component which may have various solution implementations (somewhat similar to module_adapter). If so, it will need additional (future) commits to partition the current codes into common and solution-specific parts.
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.
Good point @johnylin76 - we have named this in a generic matter, and some of the logic will probably be generic and the other logic will be specific for Maxim only. I think it would make sense in the future to split out and partition smart amp into generic and vendor files ? @cujomalainey @mwasko any thoughts ?