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

Audio: Volume: Handle all volume ramp types #8207

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

singalsu
Copy link
Collaborator

@singalsu singalsu commented Sep 15, 2023

The first patch adds a conversion from IPC4 to SOF volume ramp types.

The second patch changes further volume to be able to handle the supported ramp types.

The third patch adds to gain.conf the other supported ramp types. The default is kept as windows fade.

@singalsu singalsu marked this pull request as ready for review September 15, 2023 12:07
@singalsu
Copy link
Collaborator Author

singalsu commented Sep 15, 2023

@ranj063 @kv2019i Does this change prevent topology to work with IPC4 reference firmware - and does it matter? If that is the case, then we need to also re-order for IPC4 the table

enum sof_volume_ramp {
or create new ipc4 specific table with windows_no_fade and windows_fade as first entries.

For performance reasons we want to enable topology to select also other (lighter) ramp types.

@@ -151,7 +159,7 @@ Class.Widget."gain" {
uuid "A8:A9:BC:61:D0:18:18:4A:8E:7B:26:39:21:98:04:B7"
no_pm "true"
cpc 10183
curve_type "fade"
curve_type "windows_fade"
Copy link
Contributor

Choose a reason for hiding this comment

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

is it still default as fade, right? how to make it configurable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, but it should be another PR (change default to "linear" and have e.g. in nocodec topologies this set into "windows_fade" to keep it tested).

The intention with this patch is to fix wrong IPC sent to firmware.

Copy link
Contributor

@btian1 btian1 Sep 18, 2023

Choose a reason for hiding this comment

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

I just heard that windows does not use tplg conf definiton, so I fully agree with Seppo's comments: default set to linear
and left windows fade to nocodec tplg.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This PR keeps operation unchanged with windows fade as default, just re-arranged the enum values.

I'd like to make a separate PR to change the default type to linear and change nocodec topology to use the windows fade curve.

@ranj063
Copy link
Collaborator

ranj063 commented Sep 15, 2023

@ranj063 @kv2019i Does this change prevent topology to work with IPC4 reference firmware - and does it matter? If that is the case, then we need to also re-order for IPC4 the table

enum sof_volume_ramp {

or create new ipc4 specific table with windows_no_fade and windows_fade as first entries.
For performance reasons we want to enable topology to select also other (lighter) ramp types.

@singalsu im not sure if this will affect the ref fw. But AFAIK this wouldnt be the first thing that breaks the ref fw. Maybe we should limit to testing just the passthrough pipelines with the ref fw to avoid any issues.

@singalsu
Copy link
Collaborator Author

@ranj063 @kv2019i Does this change prevent topology to work with IPC4 reference firmware - and does it matter? If that is the case, then we need to also re-order for IPC4 the table

enum sof_volume_ramp {

or create new ipc4 specific table with windows_no_fade and windows_fade as first entries.
For performance reasons we want to enable topology to select also other (lighter) ramp types.

@singalsu im not sure if this will affect the ref fw. But AFAIK this wouldnt be the first thing that breaks the ref fw. Maybe we should limit to testing just the passthrough pipelines with the ref fw to avoid any issues.

We could

  • Decide to change the ramp enum types for IPC4 so that SOF volume would remain compatible with Windows driver. In this case the binary would be compatible.
  • Or make the enums reference FW compatible with a kconfig build option
  • Ignore the difference and test with pass-through topologies only the reference FW

What should we do?

@singalsu singalsu force-pushed the tplg_fix_gain_curve_types branch from 23fb338 to fb4db2b Compare September 18, 2023 10:04
@singalsu singalsu changed the title Tools: Topology2: Fix the gain.conf curve_type values IPC: topology.h: Fix enum sof_volume_ramp compatibility in IPC4 Sep 18, 2023
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Hmm, the condition enum def is a problem. Can we have a separate enum for IPC4?

@@ -156,6 +166,7 @@ enum sof_volume_ramp {
SOF_VOLUME_WINDOWS_FADE,
SOF_VOLUME_WINDOWS_NO_FADE,
};
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ouch, this is a problem. We have these definitions also in Linux kernel and we can't have #ifdef for IPC version. So if we need separate definitions, we need to use a different name.

Copy link
Contributor

@btian1 btian1 Sep 19, 2023

Choose a reason for hiding this comment

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

@kv2019i ,seems sof driver does not have this definition.
@singalsu , if remove ipc3 sof_volume_ramp, then we can change:
image

then all ipc3 and ipc4 are aligned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kv2019i As other fix approach could duplicate all ramp types to

enum ipc4_curve_type {
and add a conversion function from enum ipc4_peak_volume_param to enum sof_volume_ramp. What do you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@singalsu Can we have separate enums for IPC3 and IPC4 and also remove the unused enum in kernel? I think that would be the cleanest (no ifdefs in headers, no mismatch between definitions between kernel and FW).

@singalsu
Copy link
Collaborator Author

Re-request review from everyone since the patch is now very different. Hopefully like @kv2019i suggested. Since the code now touches a part with known issue I included also fix for code that prevented other than windows fade to work in ipc4 build.

@singalsu singalsu changed the title IPC: topology.h: Fix enum sof_volume_ramp compatibility in IPC4 IAudio: Volume: Handle all volume ramp types Sep 20, 2023
IPC4_AUDIO_CURVE_TYPE_LINEAR,
IPC4_AUDIO_CURVE_TYPE_LOG,
IPC4_AUDIO_CURVE_TYPE_LINEAR_ZC,
IPC4_AUDIO_CURVE_TYPE_LOG_ZC,
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this sequence, 0, with windows fade, and then linear.
it brings:

  1. compatible with windows.
  2. easy to remove later curve type.

#endif
#if CONFIG_COMP_VOLUME_LINEAR_RAMP
case SOF_VOLUME_LINEAR:
case SOF_VOLUME_LINEAR_ZC:
Copy link
Contributor

Choose a reason for hiding this comment

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

does LINEAR_ZC also use same ramp?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes both use the linear equation.

cd->initial_ramp = Q_MULTSR_32X32((int64_t)curve_duration,
Q_CONVERT_FLOAT(1.0 / 10000, 31), 0, 31, 0);
if (cd->ramp_type == SOF_VOLUME_WINDOWS_NO_FADE)
cd->initial_ramp = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to add:
cd->ramp_finished = true;
to fast skip the ramp in process.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good catch, I'll add it and test it.

@singalsu singalsu changed the title IAudio: Volume: Handle all volume ramp types Audio: Volume: Handle all volume ramp types Sep 21, 2023
@RanderWang
Copy link
Collaborator

@ranj063 @kv2019i Does this change prevent topology to work with IPC4 reference firmware - and does it matter? If that is the case, then we need to also re-order for IPC4 the table

enum sof_volume_ramp {

or create new ipc4 specific table with windows_no_fade and windows_fade as first entries.

For performance reasons we want to enable topology to select also other (lighter) ramp types.

Actually the old SOF definition is conflicted with windows usage. This PR makes it aligned with windows

enum CurveType
{
    AUDIO_CURVE_TYPE_NONE = 0,
    AUDIO_CURVE_TYPE_WINDOWS_FADE = 1
};

@singalsu singalsu force-pushed the tplg_fix_gain_curve_types branch from 655f5c7 to 8947ed1 Compare September 21, 2023 13:11
@singalsu singalsu force-pushed the tplg_fix_gain_curve_types branch from 8947ed1 to 92aa144 Compare September 25, 2023 10:54
@lgirdwood
Copy link
Member

@kv2019i did enum get fixed to your approval ?

@singalsu
Copy link
Collaborator Author

singalsu commented Oct 3, 2023

"46 successful and 1 failing checks" , rebase and retry with same patch.

This patch adds to enum ipc4_curve_type in peak_volume.h
ramp types for linear and logarithmic with and without zero
crossings detect. The conversion function
ipc4_curve_type_convert() converts the type into
enum sof_volume_ramp for use in volume.c.

The set_volume_ipc4() is changed to use the convert function
and the restriction to select other than windows fade type also
is removed.

Signed-off-by: Seppo Ingalsuo <[email protected]>
The windows fade, windows no fade, and linear and handled
the switch-case statement change into volume.c.

In IPC4 the ramp can be disabled with zero curve duration or with
no fade type. The ramp duration convert multiplication can be passed
with the no fade type.

Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds the other SOF volume ramp types linear and
logarithmic with and without zero crossings detect mode to gain
widget class. The names of fade values are changed to be similar
as in enum sof_volume_ramp, since there is a specific curve
shape required for Windows OS.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu singalsu force-pushed the tplg_fix_gain_curve_types branch from 92aa144 to ff098ce Compare October 3, 2023 15:10
@lgirdwood
Copy link
Member

"46 successful and 1 failing checks" , rebase and retry with same patch.

Unrelated Zephyr build issue.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks @singalsu , looks good now!

@kv2019i kv2019i merged commit 51159d8 into thesofproject:main Oct 4, 2023
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants