Skip to content

KWD: merge with release branch - #1462

Merged
tlauda merged 12 commits into
thesofproject:masterfrom
mrajwa:ghw_release
Jun 11, 2019
Merged

tlauda merged 12 commits into
thesofproject:masterfrom
mrajwa:ghw_release

Conversation

@mrajwa

@mrajwa mrajwa commented May 21, 2019 •

Copy link
Copy Markdown
Contributor

This PR adds latest patches from KWD release branch glk-012-stable-branch into SoF master.
The functionality is tested and works properly. Sporadically we still observe #1406 issue.

Signed-off-by: Marcin Rajwa marcin.rajwa@linux.intel.com

@mrajwa
mrajwa requested review from a team, lbetlej, lgirdwood, mmaka1 and plbossart as code owners May 21, 2019 12:56

@keyonjie keyonjie left a comment

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.

Basically looks good to me, several comments inside the commits.

Comment thread src/include/sof/audio/kpb.h 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 we rename this to sth easier to be understood? It is actually real-time copy(do in kpb_copy(), not in draining), not "draining" at all?

@mrajwa mrajwa May 29, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@keyonjie, I think it is now understandable and according to cAVS naming convention:
KPB_STATE_BUFFERING -> kpb is buffering incoming data into history buffer
KPB_STATE_DRAINING -> kpb is draining data out of internal history buffer to host (no buffering or any other copy is performed in this state)
KPB_STATE_DRAINING_ON_DEMAND -> kpb copies incoming, real time data directly to host (no buffering)

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.

@mrajwa I assume that this change replaces #1435? I must agree with @keyonjie. KPB_STATE_DRAINING_ON_DEMAND sounds like some kind of different type of draining. KPB_STATE_COPYING makes much more sense. Also I'm not sure how are we addressing the problem with potential loss of data between start and end of draining. @lbetlej Was it agreed to fix it in the future PRs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

KPB_STATE_DRAINING_ON_DEMAND sounds like some kind of different type of draining

According to cAVS documentation it is another version of draining. Guys I just wanted to code according to that document so we are consistent across platforms. However since you feel like this is not very clear we can change KPB_STATE_DRAINING_ON_DEMAND to KPB_STATE_HOST_COPY would it be OK for you?

PS: I assume all other KPB state are fine for you and we only disscuss the KPB_STATE_DRAINING_ON_DEMAND ?

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.

@mrajwa That would be OK.

Comment thread src/include/uapi/user/detect_test.h Resolved
Comment thread src/include/uapi/user/detect_test.h Resolved
Comment thread src/audio/detect_test.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.

Here the naming "keyphrase_length" sounds more reasonable to me. :P

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.

Or "keyphrase_ms"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here the naming "keyphrase_length" sounds more reasonable to me. :P

Hah really? To me "keyphrase length" is just confusing. It suggest how much buffered data we want to get which is what history_depth does. preamble_time however clearly says "After what time detection shall be activated?"

@lgirdwood what do you think?

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.

@mrajwa do you mean that those data before preamble_time will be ignored and dropped?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@keyonjie, they are ignored but not dropped - they will always be stored in history buffer inside KPB but detector won't trigger detection before preamble time is over.

Comment thread src/audio/detect_test.c Resolved
Comment thread src/audio/detect_test.c Resolved
Comment thread src/audio/detect_test.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.

Here you are adding more and more dependencies to kpb? @slawblauciak what do you think about this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could discuss if it is good or bad however I decided to set this default preamble to 0 as this seems to be more natural. By default you expect KWD to be active from start, right?

Comment thread src/audio/kpb.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.

How shall we handle it once we are running with 24bit captured data? better to get it from fmt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The support for more sampling options will be provided as separate patch.

Comment thread src/audio/kpb.c Resolved

@jajanusz jajanusz left a comment

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.

Code itself looks ok, but do we have change for uapi/* headers in kernel?

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mrajwa I stopped reviewing at patch 2 as I had no idea what each patch was trying to achieve. Please use the commit messages to explain what, why and how.

@mrajwa

mrajwa commented May 29, 2019

Copy link
Copy Markdown
Contributor Author

Code itself looks ok, but do we have change for uapi/* headers in kernel?

@jajanusz, no we don't have to update kernel side.

@wenqingfu
wenqingfu requested a review from singalsu May 29, 2019 22:02

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some commits still missing a commit message. Memory commit needs removed.

Comment thread src/audio/kpb.c Resolved
@mrajwa

mrajwa commented May 30, 2019

Copy link
Copy Markdown
Contributor Author

@lgirdwood, this PR has been updated. Please review and lets merge it as it is the base for further 24 bit support.

Comment thread src/include/sof/audio/kpb.h 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.

@mrajwa I assume that this change replaces #1435? I must agree with @keyonjie. KPB_STATE_DRAINING_ON_DEMAND sounds like some kind of different type of draining. KPB_STATE_COPYING makes much more sense. Also I'm not sure how are we addressing the problem with potential loss of data between start and end of draining. @lbetlej Was it agreed to fix it in the future PRs?

Comment thread src/audio/detect_test.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.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.

It is highly desirable to use buffer_write_frag API here to handle potential buffer wrap-ups.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree, added function which do care about it. Once this PR is merged I will create some container which keeps different copy function for different format and they will be selected by looking up cd->config.sampling_width

Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/include/sof/audio/kpb.h 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.

@mrajwa That would be OK.

Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/detect_test.c Resolved
Comment thread src/audio/kpb.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.

Could we change function names to be aligned with the rest of processing components?
Also I don't think we need to specify number of channels, since your functions are universal.
kpb_copy_s16
kpb_drain_s16

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have yet another idea, lets call them kpb_copy_samples and kpb_drain_samples and inside these function decide what buffer_read/write API to choose by format. Although for this PR selecting different samples format is out of scope as it is will be covered in different PR.

Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.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.

Is this really needed? I thought we are returning PPL_STATUS_PATH_STOP on draining. I would really like to avoid setting component's state internally without kernel's knowledge. I guess detect pipeline should be stopped explicitly by the host on received notification? @lbetlej Any thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree this setting here is redundant as well as kernel taking care of it. The only concern I have is timing. I mean when we get FW notification about detection we can stop further copy imediately inside FW. Kernel on the other hand first need to wait for IPC about notification, then send another one aimed to stop some pipeline.

@tlauda

tlauda commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

@lgirdwood @plbossart uapi/user/detect_test.h is changed, so it looks like ABI should be incremented, but I'm a little bit confused. Kernel apparently doesn't use uapi/user/* headers at all, so from kernel's perspective it is backward compatible. However any user client using this won't be, so do we need another ABI?

@lgirdwood

Copy link
Copy Markdown
Member

@tlauda we use same ABI for usespace, that way it can check if both kernel and FW support the feature. Likewise FW and kernel can check userspace for ABI feature alignment based on the same data.

@mrajwa

mrajwa commented Jun 6, 2019

Copy link
Copy Markdown
Contributor Author

@tlauda, I am bit confused why would you like to introduce another ABI? The new field used in uapi/user/detect_test.h is used only inside FW and passed from outside in form of topology file right?

@tlauda

tlauda commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

@mrajwa Because now you need to create PR for kernel just to increase ABI number, which will look totally weird.

@jajanusz

jajanusz commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

@lgirdwood @tlauda @mrajwa
If we are going keep 1 ABI version, then yes, you are going to have PRs to kernel that just bump abi version and provide no new content, if headers were just for userspace apps.

But I don't know if having 2 versions is better.

@mrajwa

mrajwa commented Jun 6, 2019

Copy link
Copy Markdown
Contributor Author

So, what should I do next, to me opening a PR in kernel repository which only update ABI version doesn't sound reasonable. @lgirdwood, @plbossart, what do you think?

@lgirdwood lgirdwood added the ABI ABI change involved label Jun 6, 2019
@lgirdwood

Copy link
Copy Markdown
Member

@mrajwa no need to update kernel if this is user only. I've assigned MINOR 8. Not need to bump ABI as there are other PRs pending for MINOR 8 (last PR merged will bump)

mrajwa added 2 commits June 7, 2019 12:06
This patch adds new state KPB_STATE_DRAINING. In this
state kpb drains data from internal history buffer to
host sink bypassig any other component. In the same
time internal buffering is turned off.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Detector was using keyphrase_length to:
1. delay detection
2. to calculate the amount of data that shall be
drained from history buffer.

This was confusing people, therefore we use two
separate variables name with better naming.

1. history_depth -> to define default draining
request. (in bytes)
2. preamble_time -> to define delay after which
detection should be active.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
mrajwa added 5 commits June 7, 2019 12:36
This patch provides default parameters for newly added
detect_preamble and history_depth. Both by default are
set to max buffering time of KPB.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Remove history_begin and history_end members from
kpb as they are not used anywhere.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch adds two new trace messages into draining
task - the amount of drained data and time needed to
drain them in milliseconds.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Remove unnecessary check of preamble time. Previously
it was allowing preamble time smaller than kpb buffering
time. There is no reason for such a constrain.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
With this patch default preamble is set to zero
meaning KWD is activated from start, no delay.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@mrajwa

mrajwa commented Jun 10, 2019

Copy link
Copy Markdown
Contributor Author

@lgirdwood @tlauda can we merge this PR? This week we have another KWD release and this is prerequisite.

@tlauda tlauda left a comment

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.

Ready for approval after update of function descriptions.

Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
mrajwa added 3 commits June 10, 2019 12:16
memcpy function doesn't care about "wrap-ups"
and sample sizes which are crucial in copy
of audio signals.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Kpb rt_sink is confusing and was replaced with
sel_sink which stands for selector sink - the component
to which KPB copies during BUFFERING state. Likewise
the cli_sink was replaced to host_sink clearly stating
that we copy out of DSP.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
After detection of keyword we shall stop further copy to selector
pipeline. We do this in regular copy() function so there is no need
to do it also in init_draining() function.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@mrajwa

mrajwa commented Jun 10, 2019

Copy link
Copy Markdown
Contributor Author

@tlauda, I have just updated.

The CLK_CPU macro is undefined for imx8 platform therefore
shall be added.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@lgirdwood

Copy link
Copy Markdown
Member

@mrajwa UT failing.

KPB source code started to use timer related features
therefore cmocka tests need to include these
dependencies.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@mrajwa

mrajwa commented Jun 11, 2019

Copy link
Copy Markdown
Contributor Author

@lgirdwood, updated.

@tlauda
tlauda merged commit fb111cd into thesofproject:master Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ABI ABI change involved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants