Skip to content

Volume: Use ramp tokens and define the ramp tokens in all topologies - #1373

Merged
lgirdwood merged 2 commits into
thesofproject:masterfrom
singalsu:volume_use_ramp_tokens
May 9, 2019
Merged

lgirdwood merged 2 commits into
thesofproject:masterfrom
singalsu:volume_use_ramp_tokens

Conversation

@singalsu

@singalsu singalsu commented May 6, 2019 •

Copy link
Copy Markdown
Collaborator

This PR consists of two commits. The first contains the changes for volume component. The second updates all topologies to define the volume ramp tokens. This approach does not need kernel update.

I removed the [RFC][Do not merge] labels since the code now seems to pass the CI tests.

@singalsu

singalsu commented May 7, 2019

Copy link
Copy Markdown
Collaborator Author

@emilchudzik @zrombel This is the fix for issue #1297. Does the CI test set the volume new() IPC parameters initial_ramp and ramp? The parameter ramp should be set to 0 (SOF_VOLUME_LINEAR) and initial_ramp to e.g. 250 to preserve the current linear ramp slope. If initial_ramp is left to zero the volume jumps directly to new gain value and it could trigger an error in CI testst.

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Empty line not needed.

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be done in one trace message.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh, sorry, that's something I was about to remove. But on the other hand it could be useful to preserve and cleanup like you suggest.

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be done in one trace message.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The trace in params() is redundant, they are available in new().

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding ABS macro would be useful.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, will do.

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be done in one trace message.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These are something to remove. I was just checking that the code is sane with these.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These would be removed, or maybe converted to tracev().

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be done in one trace message.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Also these are not needed. The t_us recompute is just for trace and can be removed also.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This could be tracev().

@zrombel

zrombel commented May 7, 2019

Copy link
Copy Markdown

@singalsu at this point in test we are using ramp=SOF_VOLUME_LINEAR and initial_ramp=0. I tested this PR manually and initial_ramp parameter seems to work correctly. We will set initial_ramp to 250 for current tests and prepare cases to test initial_ramp parameter. I see that at this point only SOF_VOLUME_LINEAR is supported. @singalsu do you plan to implement other ramp shapes in this PR?

@singalsu

singalsu commented May 7, 2019 •

Copy link
Copy Markdown
Collaborator Author

@zrombel Good, thanks for adding ramp time into tests! This PR will support only linear ramp. I'll enter an enhancement issue for logaritmic ramp and do it later. It's simple to add but will need exp() function into SOF math library. The zero crossings timed volume updates need more work (replace vol_work) but are possible and feasible also (avoid clicks when adjusting). Those could have another enhancement issue.

@singalsu
singalsu force-pushed the volume_use_ramp_tokens branch from c5b115f to 92ef599 Compare May 7, 2019 11:28
@singalsu

singalsu commented May 7, 2019

Copy link
Copy Markdown
Collaborator Author

@tlauda I've now addressed your comments. I'm not totally sure why MIN() and MAX() are done like they are now but I followed the example with new ABS() function. I didn't add saturation to ABS. We could have a saturating inline function as well like abs_int32(). This macro is for generic use known not to wrap.

@singalsu

singalsu commented May 8, 2019

Copy link
Copy Markdown
Collaborator Author

Thanks @tlauda @zrombel for the review effort! I'll change this to normal PR now.

@singalsu
singalsu force-pushed the volume_use_ramp_tokens branch from 92ef599 to b44c7f7 Compare May 8, 2019 08:09
@singalsu singalsu changed the title [RFC][Do not merge]Volume use ramp tokens Volume use ramp tokens May 8, 2019
@singalsu

singalsu commented May 8, 2019

Copy link
Copy Markdown
Collaborator Author

The code is same as in previous PR version. I updated the commit title and improved a bit the commit body text.

@singalsu singalsu changed the title Volume use ramp tokens Volume: Use ramp tokens and define the ramp tokens in all topologies May 8, 2019
Comment thread src/audio/volume.h Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@singalsu is this comment correct? where is ramp_length_ms in the macro below?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, need to fix this comment.

Comment thread src/audio/volume.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@singalsu for my understanding when will this ever happen? the target volume is limited to VOL_MAX or VOL_MIN. so the delta can ever be maximum of VOL_ZERO_DB isnt it?

@singalsu singalsu May 9, 2019 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ranj063 This happens pretty often when volume control is above 0 dB. This step re-calculate is the beef of the slow gain settling fix (while kernel does not provide the used min/max range).

VOL_MAX is +42 dB so the the linear mute->unity gain equal transition is only e.g. 0 dB -> +6 dB jump. Such and much larger volume transitions can be made by pressing keys 0 - 9 in alsamixer ASCII graphics view.

@wenqingfu

Copy link
Copy Markdown

does this need corresponding driver change? @singalsu

@ranj063

ranj063 commented May 9, 2019

Copy link
Copy Markdown
Collaborator

does this need corresponding driver change? @singalsu

@wenqingfu I dont think so. The volume tokens are already parsed by the driver.

@singalsu

singalsu commented May 9, 2019

Copy link
Copy Markdown
Collaborator Author

@wenqingfu To me this approach appears to work fine without kernel update. I can enter an enhancement issue for Linux to pass the actual min/max range per volume instance so we could have always constant rate ramp. But I feel the priority for enhance is low. FW could be compatible current and such future kernel by checking if min and max from IPC. If both are zeros like today use this slope recalculation to never exceed slope max time. When max > 0 use max - min directly for step calculate.

There would be a bit more FW changes anyway if I implement the log ramp. I checked meanwhile that doing fractional log() function is fairly straightforward. It doesn't take many series iterations to compute to less than 0.1 dB error.

Currently attempt to set log ramp in topology fails cleanly when instantiating topology.

singalsu added 2 commits May 9, 2019 11:54
This patch adds code to handle volume ramp type and ramp length
parameters from topology. The previous hard coded 250 ms ramp
related macros are removed.

Since the kernel does not (yet) provide the volume min/max into
as IPC for new() the code assumes the ramp length is the length
of the mute to 0 dB gain transition.

If a volume transition is larger than that, what can happen in a
high gain configuration, the ramp is shortened to exceed the
passed time parameter. So in other words the large transitions will
use a variable rate slope.

Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds volume configuration tokens as fifth parameter
for pga.m. All the topologies those use W_PGA() are updated to
use a linear (type=0) ramp with length of 250 ms.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu
singalsu force-pushed the volume_use_ramp_tokens branch from b44c7f7 to d57830e Compare May 9, 2019 08:55
@lgirdwood

Copy link
Copy Markdown
Member

@singalsu does min/max range require an ABI change ?

@lgirdwood
lgirdwood merged commit 7dd76db into thesofproject:master May 9, 2019
@singalsu

Copy link
Copy Markdown
Collaborator Author

@lgirdwood There's no need for ABI change, the fields are just zeros now. I think I should implement in FW side the code to utilize the min/max when it will be made available by kernel driver. It's easy to make such test driver version with fixed values to test. For actual kernel work to extract the volume scale I've filed an enhancement issue.

@singalsu
singalsu deleted the volume_use_ramp_tokens branch May 10, 2019 07:15
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.

6 participants