Skip to content

Conversation

@yongzhi1
Copy link
Contributor

Use lbm_mode to loopback playback data for PCM27.

Signed-off-by: Yong Zhi yong.zhi@intel.com

@yongzhi1 yongzhi1 marked this pull request as draft December 21, 2022 20:50
@yongzhi1 yongzhi1 marked this pull request as ready for review January 3, 2023 21:50
@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 4, 2023

This is for MAX98357A speaker amp which does not have IV feedback capability, I am not sure about any side effect of lbm_mode, other than that any comments/suggestion?

@bardliao
Copy link
Collaborator

bardliao commented Jan 5, 2023

@yongzhi1 Using LBM makes sense to me.

@yongzhi1 yongzhi1 changed the title [TEST] topology2: add reference capture for MAX98357A speaker amp topology2: add reference capture for MAX98357A speaker amp Jan 6, 2023
@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 6, 2023

@yongzhi1 Using LBM makes sense to me.

Ack, tested working with arecord based on sof-dev kernel.

@lgirdwood
Copy link
Member

This is for MAX98357A speaker amp which does not have IV feedback capability, I am not sure about any side effect of lbm_mode, other than that any comments/suggestion?

Not sure why we need to fake IV feedback here with loop back ? Can you provide context.

Fwiw, The code looks fine so if not suitable for this use case could be used for testing.

@plbossart
Copy link
Member

In addition to @lgirdwood the open is "Why do we need an echo reference"?
This is only needed if there is a non-linear processing such as DRC or Waves or others on the speaker playback path, or if you wanted to use AEC in the DSP but that's not what this topology change does.
@yongzhi1 can you add a bit more context here?

@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 7, 2023

Not sure why we need to fake IV feedback here with loop back ? Can you provide context.

My understanding is that we did the same for max98360a, we now get the loopback data at I2S instead of MUXDEMUX as shown in sof-adl-max98360a-rt5682.tplg:

sof-adl-max98360a-rt5682
https://github.com/thesofproject/sof/blob/main/tools/topology/topology1/sof-tgl-max98357a-rt5682.m4
thesofproject/linux@f316c9d

@plbossart
Copy link
Member

Not sure why we need to fake IV feedback here with loop back ? Can you provide context.

My understanding is that we did the same for max98360a, we now get the loopback data at I2S instead of MUXDEMUX as shown in sof-adl-max98360a-rt5682.tplg:

sof-adl-max98360a-rt5682 https://github.com/thesofproject/sof/blob/main/tools/topology/topology1/sof-tgl-max98357a-rt5682.m4 thesofproject/linux@f316c9d

nope, this is using the loopback with the demux. The SSP0 is only used because we need a DPCM backend, this is the reason why we had issues with the updated kernel where the .dpcm_capture field was not set. thesofproject/linux#4083

@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 7, 2023

nope, this is using the loopback with the demux. The SSP0 is only used because we need a DPCM backend, this is the reason why we had issues with the updated kernel where the .dpcm_capture field was not set. thesofproject/linux#4083

Hi, @plbossart, yes, totally agree with above, think @bardliao also followed same approach to use copier-as-demux initially #6657.

@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 7, 2023

In addition to @lgirdwood the open is "Why do we need an echo reference"? This is only needed if there is a non-linear processing such as DRC or Waves or others on the speaker playback path, or if you wanted to use AEC in the DSP but that's not what this topology change does. @yongzhi1 can you add a bit more context here?

Hi, @plbossart , to use ACE in the DSP, I’d be tempted to follow #6601, but it's a little over-kill to have "three copier.module for a simple demux functionality.".

Hi, @sathya-nujella , what's your opinion on above "Why do we need" question?

@sathya-nujella
Copy link
Contributor

In addition to @lgirdwood the open is "Why do we need an echo reference"? This is only needed if there is a non-linear processing such as DRC or Waves or others on the speaker playback path, or if you wanted to use AEC in the DSP but that's not what this topology change does. @yongzhi1 can you add a bit more context here?

Yes. In playback path Post Processing/non-linear processing module would be enabled. Hence the requirement is to give this as echo ref PCM to CRAS/user space.

@bardliao
Copy link
Collaborator

bardliao commented Jan 9, 2023

@plbossart This PR is trying to get reference with loop back mode which should have the same result as getting reference from a demux like sof-adl-max98360a-rt5682.tplg does and will be simpler.

@lgirdwood
Copy link
Member

@bardliao @yongzhi1 is this PR for the "dummy" module testing only ? i.e. testing all the paths/PCMs ?

@yongzhi1 yongzhi1 force-pushed the ref-cap-for-dumb-amp branch from c062233 to 7daa73b Compare January 9, 2023 17:55
@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 9, 2023

V2:

Added copier module in the pipeline to use as demux.

sof-mtl-max98357a-rt5682

@lgirdwood
Copy link
Member

@bardliao @yongzhi1 is this PR for the "dummy" module testing only ? i.e. testing all the paths/PCMs ?

@yongzhi1 sorry, I'm not clear if we are looping back real smart amp feedback data here or fake (using the LBM) here.

@yongzhi1
Copy link
Contributor Author

@yongzhi1 sorry, I'm not clear if we are looping back real smart amp feedback data here or fake (using the LBM) here.

Hi, @lgirdwood, MAX98357A is a dumb amp that does not support feedback data in PCM, so it's "fake" (not true IV).

@lgirdwood
Copy link
Member

@yongzhi1 sorry, I'm not clear if we are looping back real smart amp feedback data here or fake (using the LBM) here.

Hi, @lgirdwood, MAX98357A is a dumb amp that does not support feedback data in PCM, so it's "fake" (not true IV).

Thanks @yongzhi1, got you, that was confusing me. @plbossart is this the OK for you ?

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

not getting why there's both LBM and demux (with the copier).

Copy link
Member

Choose a reason for hiding this comment

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

why are we using LBM mode if there's a demux?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @plbossart , the demux is put on capture pipeline to connect with ACE module in the future.

Copy link
Member

Choose a reason for hiding this comment

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

can you share the picture of the new topology, will be easier to see. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @plbossart

Here is the picture with copier.module.8.2 added:
#6880 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Are you saying that copier.module.8.2 would have at some point additional sinks connected? I am struggling between what you want now and what will be done later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @plbossart , yes, that's my current thoughts, something like this (sorry for the ugly flow chart):

graph TD;
   SSP.IN-->copier.module.8.2;
   copier.module.8.2 --> echo-ref-PCM;
   copier.module.8.2 --> AEC;
    subgraph ide1 [future]

   PDM --> AEC;
   AEC --> DMIC48K;
end
Loading

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we expand the comment to say reference capture please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you need to set this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I just followed the example of similar place like:
https://github.com/thesofproject/sof/blob/main/tools/topology/topology2/cavs-nocodec.conf#L289
It's more out of convention than necessity.

Copy link
Collaborator

Choose a reason for hiding this comment

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

lets not set it blindly if it is not needed,

Copy link
Collaborator

Choose a reason for hiding this comment

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

pcm.2 please. Lets keep it incremental as it is really only an instance ID.

Copy link
Contributor Author

@yongzhi1 yongzhi1 Jan 24, 2023

Choose a reason for hiding this comment

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

Ack, here I followed #6783 (comment) to use 27 for PCM, yes, the ID can be 2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yongzhi1 the 27 is set below in the ID attribute. What I mean was the instance ID here doesnt need to match it

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we please wait till #6986 merged and update this to use instance ID to instantiate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make this string "Echo reference" a variable defined in the Define {} block so you can use it here and in the pcm caps object below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

Copy link
Collaborator

Choose a reason for hiding this comment

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

this route can go into the pipeline definition passthrough-copier-be.conf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me think about it, thanks for your review!!

@yongzhi1 yongzhi1 force-pushed the ref-cap-for-dumb-amp branch from 7daa73b to d0e0e6c Compare January 25, 2023 23:37
@yongzhi1
Copy link
Contributor Author

V3 update:

  1. rebase the code.
  2. add variables for "Echo reference" and pipeline ID etc.
  3. remove useless stream_name "SSP0-Codec".
  4. echo ref related PCM, Dai instance & route index all start from 200.
  5. add INCLUDE_ECHO_REF for conditional include.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why 200? please use incremental values so 1 in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, the 200 serves as a warning that this instance was referenced elsewhere, do not change one place without changing another .. . will use incremental values for this and other places (route index etc.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yongzhi1 its the other way around, only included files need to set large instance IDs atm. top-level files should not. But in any case once my alsautils PR is merged, we'll not need to worry about this

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we call it dai-copier-buffer.conf? all copiers are capable of format conversion. So its not just passthrough anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack,

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a PR submitted to alsautils alsa-project/alsa-utils#188 to avoid such collisions in the alsatplg compiler instead of having to do this manually.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not use "dumb" in the name of the file please. Can you call this simply speaker-echo-ref.conf? What makes this exclusive to not-so-smart amps? When needed, the same file could be included in the case of smart amps too right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree the file name is rather dumb, for amps with IV data, we do not need the lbm_mode. Will update the file name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

similarly for direction here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, will update in V4.

@yongzhi1 yongzhi1 force-pushed the ref-cap-for-dumb-amp branch from d0e0e6c to 28d05bb Compare January 26, 2023 17:21
@yongzhi1
Copy link
Contributor Author

yongzhi1 commented Jan 26, 2023

V4 update:

  1. rename 2 new files
  2. remove redundant settings (i.e. name, direction) in child object.
  3. use incremental values for PCM instance id at top file and included file speaker-echo-ref.conf.

ranj063
ranj063 previously approved these changes Jan 26, 2023
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's only 1 audio format

Copy link
Contributor Author

@yongzhi1 yongzhi1 Jan 26, 2023

Choose a reason for hiding this comment

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

Ack, cut & paste error :)
I saw it was fixed by 48afcef

Copy link
Collaborator

Choose a reason for hiding this comment

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

are these period counts really useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must admit I do not know.

Copy link
Collaborator

Choose a reason for hiding this comment

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

lets remove it. im pretty sure these are not used in ipc4

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yongzhi1 lets not do this. My alsauilts PR will not allow object overrides. You need to set the direction and lbm mode to duplex is INCLUDE_ECHO_REF is true in the top-level file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lbm_mode is the only valid value for SSP quirks, I will think about your suggestion.
!valid_values [ "lbm_mode" ]

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yongzhi1 what you need is something like this. You will need the latest upstream alsa-utils for this to work.

diff --git a/tools/topology/topology2/cavs-rt5682.conf b/tools/topology/topology2/cavs-rt5682.conf
index b04957d99..e13bc362c 100644
--- a/tools/topology/topology2/cavs-rt5682.conf
+++ b/tools/topology/topology2/cavs-rt5682.conf
@@ -116,7 +116,15 @@ Object.Dai {
        SSP."1" {
                id              $SPK_ID
                dai_index       $SPEAKER_SSP_DAI_INDEX
+IncludeByKey.INCLUDE_ECHO_REF {
+"false" {
                direction       "playback"
+       }
+"true" {
+               direction       "duplex"
+               quirks          "lbm_mode"
+       }
+}
                name            $SPEAKER_CODEC_NAME
                default_hw_conf_id      0
                sample_bits             32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, fortunately I waited a while before attempting the changes, the new capability arrived to rescue at the right moment:
alsa-project/alsa-utils@1350900

@ranj063 ranj063 dismissed their stale review January 26, 2023 17:43

mistakingly clicked on approve

@yongzhi1 yongzhi1 force-pushed the ref-cap-for-dumb-amp branch from 28d05bb to 1dd9a32 Compare January 26, 2023 21:39
Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW @yongzhi1 if you want to give it a try. you can start your object instances from 1 for the pcm and routes in this conf file with this PR alsa-project/alsa-utils#188. The compiler will take care of avoiding clashes with the top-level file objects

Copy link
Member

Choose a reason for hiding this comment

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

Lets do this as part of the topology2 feature cleanup. @jsarha fyi.

@yongzhi1
Copy link
Contributor Author

V5 update

  1. use new IncludeByKey for conf block support instead of obj override to manage conditional inclusion.
  2. did not find clear usage/definitions of period_source_count/period_sink_count, so remove them
  3. fix format number from 2 to 1.

@yongzhi1 yongzhi1 marked this pull request as draft January 26, 2023 21:51
@yongzhi1 yongzhi1 marked this pull request as ready for review January 27, 2023 00:29
Use lbm_mode to loopback playback data for PCM27.
Add copier module in DAI BE for demux function.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
@yongzhi1 yongzhi1 force-pushed the ref-cap-for-dumb-amp branch from 1dd9a32 to 805ab3e Compare January 27, 2023 00:35
@yongzhi1
Copy link
Contributor Author

Pushed for SOFCI TEST.

@ranj063
Copy link
Collaborator

ranj063 commented Jan 27, 2023

SOFCI TEST

@ranj063 ranj063 requested a review from plbossart January 27, 2023 01:30
@lgirdwood lgirdwood merged commit 594e3f7 into thesofproject:main Feb 1, 2023
@kv2019i
Copy link
Collaborator

kv2019i commented Feb 1, 2023

@yongzhi1 @ranj063 @lgirdwood I think we have a problem. This doesn't build and for some reason, pr-tools-build is not running topology2 check. FYI @marc-hb @greg-intel @fredoh9 @keqiaozhang

@juimonen
Copy link

juimonen commented Feb 1, 2023

so we need very latest alsa-utils for this, where ever it needs to be updated...

@kv2019i
Copy link
Collaborator

kv2019i commented Feb 1, 2023

Yes, the tplg2 coverage seems ok after all, so this was a false alarm. One does need to have a recent alsa-utils to have the build work, but the CI checks seem good with regard to this.

@ranj063
Copy link
Collaborator

ranj063 commented Feb 1, 2023

@yongzhi1 @ranj063 @lgirdwood I think we have a problem. This doesn't build and for some reason, pr-tools-build is not running topology2 check. FYI @marc-hb @greg-intel @fredoh9 @keqiaozhang

@kv2019i the CI docker image has been updated with the latest alsa-utils. The build did pass right?

@marc-hb
Copy link
Collaborator

marc-hb commented Feb 1, 2023

Yes this builds ONLY if you update your docker image maintained by @fredoh9

docker pull thesofproject/sof 
./scripts/docker-run.sh ./scripts/build-tools.sh

@marc-hb
Copy link
Collaborator

marc-hb commented Feb 1, 2023

or some reason, pr-tools-build is not running topology2 check.

URL? This one looks OK https://sof-ci.01.org/sofpr/PR6880/build3554/build/tools.txt

@yongzhi1 yongzhi1 deleted the ref-cap-for-dumb-amp branch April 26, 2024 16:54
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.

9 participants