-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
intel_adsp: dmic: Refactoring of blob parsing function #60172
Conversation
ef37a85
to
2d33c77
Compare
Generally looks very nice, good cleanups again. @softwarecki can you make a sof pr with this pr in west so we can do the CI tests? |
LOG_INF("OUTCONTROL = %08x", val); | ||
LOG_INF(" tie=%d, sip=%d, finit=%d, fci=%d", bf1, bf2, bf3, bf4); | ||
LOG_INF(" bfth=%d, of=%d, ipm=%d, th=%d", bf5, bf6, bf7, bf8); | ||
if (bf5 > OUTCONTROL_BFTH_MAX) { |
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.
I agree that using a reserved bit could be just warning. But exceed of a max value like BFTH feels like it should be an error because it results to incorrect operation.
val0 = dai_dmic_read(dmic, OUTSTAT0); | ||
val1 = dai_dmic_read(dmic, OUTSTAT1); | ||
val0 = dai_dmic_read(dmic, OUTSTAT); | ||
val1 = dai_dmic_read(dmic, OUTSTAT + PDM_CHANNEL_REGS_SIZE); |
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.
I don't think this is a code improvement. Are you sure?
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.
Introduction of the PDM_CHANNEL_REGS_SIZE allows to remove a few switches, so I think this is an improvement.
drivers/dai/intel/dmic/dmic.c
Outdated
@@ -585,8 +571,7 @@ static void dai_dmic_start(struct dai_intel_dmic *dmic) | |||
|
|||
mic_a = dmic->enable[i] & 1; | |||
mic_b = (dmic->enable[i] & 2) >> 1; | |||
fir_a = (dmic->enable[i] > 0) ? 1 : 0; | |||
fir_b = (dmic->enable[i] > 0) ? 1 : 0; | |||
start_fir = !!(dmic->enable[i] > 0); |
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.
Simplify !! ?
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.
Instead of two variables with the same value, we have one, so this is a simplification. In fact, double negation is unnecessary because the comparison returns a boolean value. I will fix it.
Definitions of a configuration blob structures were separated from the main drivers header file and moved to a dedicated file to improve code readability. Removed unnecessary nhlt_pdm_fir_coeffs structure. The nhlt_pdm_ctrl_cfg structure was extended with nhlt_pdm_ctrl_fir_cfg and fir coefficients. Signed-off-by: Adrian Warecki <[email protected]>
Moved code fragments responsible for logging and verification of the configuration register values from the dai_dmic_set_config_nhlt function to a separate functions. Behavior of the code verifying the correctness of register values has been changed so that it only displays warnings. Signed-off-by: Adrian Warecki <[email protected]>
All PDM controllers have the same set of registers. Their definitions have been merged to simplify the code. Signed-off-by: Adrian Warecki <[email protected]>
Added reading of a necessary register values in dai_nhlt_dmic_dai_params_get function to simplify its parameter list. The code that calculates dai_params has been moved to it to simplify the dai_dmic_set_config_nhlt function. Signed-off-by: Adrian Warecki <[email protected]>
The while loop in the code fragments waiting for a bit to be cleared has been replaced with the WAIT_FOR macro call. Added a warning in the case of timeout. Signed-off-by: Adrian Warecki <[email protected]>
Created dai_dmic_start_fifo_packers function corresponding to an already existing dai_dmic_stop_fifo_packers. Signed-off-by: Adrian Warecki <[email protected]>
All fir filters have an identical set of registers so their definitions were combined to simplify the code. From the dai_dmic_set_config_nhlt function, a duplicate piece of code responsible for configuring fir was separated into a new function. Signed-off-by: Adrian Warecki <[email protected]>
More verbose variable pdm_idx was used instead of n. The series of references to the array of pdm base addresses has been replaced with a pdm_base variable. Signed-off-by: Adrian Warecki <[email protected]>
Added reading of a necessary register values in dai_nhlt_dmic_dai_params_get function to simplify its parameter list. The code that calculates dai_params has been moved to it to simplify the dai_dmic_set_config_nhlt function. Signed-off-by: Adrian Warecki <[email protected]>
Created set of new functions for configure fir coefficients with support for packed format. This allowed to make the dai_dmic_set_config_nhlt function simpler. Signed-off-by: Adrian Warecki <[email protected]>
d3bd045
to
cf7621e
Compare
|
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.
Thanks @softwarecki , looks good and test PR also passes. I'd like @singalsu to approve this series before merge, otherwise good to go.
p_mfir = FIELD_GET(FIR_CONFIG_FIR_DECIMATION, val) + 1; | ||
|
||
rate_div = p_clkdiv * p_mcic * p_mfir; | ||
LOG_ERR("dai_index = %d, rate_div = %d, p_clkdiv = %d, p_mcic = %d, p_mfir = %d", |
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.
@softwarecki why are these LOG_ERR()
? They seem printed every time:
This delays thesofproject/sof-test#1075 once more...
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.
@marc-hb oops, it should be LOG_INF
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.
ops, it should be LOG_INF
Fix submitted: #67567
Fix the log level of two LOG_ERR() statements which should have always been LOG_INF(). As confirmed by the author Adrian in zephyrproject-rtos#60172 Fixes commit 3fbaed4 ("dai: intel: ace: dmic: Refactor of dai_nhlt_dmic_dai_params_get function") Signed-off-by: Marc Herbert <[email protected]>
Fix the log level of two LOG_ERR() statements which should have always been LOG_INF(). As confirmed by the author Adrian in #60172 Fixes commit 3fbaed4 ("dai: intel: ace: dmic: Refactor of dai_nhlt_dmic_dai_params_get function") Signed-off-by: Marc Herbert <[email protected]>
Fix the log level of two LOG_ERR() statements which should have always been LOG_INF(). As confirmed by the author Adrian in zephyrproject-rtos#60172 Fixes commit 3fbaed4 ("dai: intel: ace: dmic: Refactor of dai_nhlt_dmic_dai_params_get function") Signed-off-by: Marc Herbert <[email protected]> (cherry picked from commit 8042e73)
Fix the log level of two LOG_ERR() statements which should have always been LOG_INF(). As confirmed by the author Adrian in zephyrproject-rtos#60172 Fixes commit 3fbaed4 ("dai: intel: ace: dmic: Refactor of dai_nhlt_dmic_dai_params_get function") Signed-off-by: Marc Herbert <[email protected]> (cherry picked from commit 8042e73)
Definitions of a configuration blob structures were moved from the main drivers header file to a dedicated file.
Moved code fragments responsible for logging and verification of the configuration register values from the dai_dmic_set_config_nhlt function to a separate functions. Behavior of the code verifying the correctness of register values has been changed so that it only displays warnings.
All PDM controllers have the same set of registers. Their definitions have been merged to simplify the code. The same was done for FIR filters registers.
Code responsible for configuring fir was separated into a new function. Created set of new functions for configure fir coefficients with support for packed format.
Added reading of a necessary register values in dai_nhlt_dmic_dai_params_get function to simplify its parameter list. The code that calculates dai_params has been moved to it to simplify the dai_dmic_set_config_nhlt function.