Handle WoV phrase detection notification and kcontrols - #5903
Handle WoV phrase detection notification and kcontrols#5903naveen-manohar wants to merge 2 commits into
Conversation
54c39e0 to
412f4a9
Compare
|
@jsarha pls review - it may be that your IPC4 wov wakeup PR overlaps here. |
jsarha
left a comment
There was a problem hiding this comment.
I think it would be best to use snd_sof_pcm_period_elapsed(), but other than that I do not see anything alarming here. Of course the final judge is, does it work?
412f4a9 to
85f6bee
Compare
Done !! |
There was a problem hiding this comment.
Pull request overview
Adds IPC4 Wake-on-Voice (WoV) phrase detection handling to the SOF driver so firmware keyword events can wake the system, notify user-space via kcontrol events, and unblock the WoV capture stream.
Changes:
- Add a new IPC4 notification handler for
SOF_IPC4_NOTIFY_PHRASE_DETECTED. - Introduce IPC4 WoV helper implementation to notify topology-defined kcontrols and trigger capture progress.
- Hook the new code into the SOF IPC4 build and notification dispatch path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sound/soc/sof/Makefile | Adds ipc4-wov.o to the IPC4 build. |
| sound/soc/sof/ipc4.c | Dispatches PHRASE_DETECTED notifications to the WoV handler. |
| sound/soc/sof/ipc4-wov.h | Declares the WoV phrase-detected handler API. |
| sound/soc/sof/ipc4-wov.c | Implements kcontrol notifications and capture unblocking on phrase detection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /* IPC4 PHRASE_DETECTED primary/extension field layout */ | ||
| #define SOF_IPC4_PHRASE_WORD_ID_MASK GENMASK(31, 24) | ||
| #define SOF_IPC4_PHRASE_WORD_ID_SHIFT 24 | ||
| #define SOF_IPC4_PHRASE_SV_SCORE_MASK GENMASK(15, 0) | ||
|
|
| list_for_each_entry(spcm, &sdev->pcm_list, list) { | ||
| if (spcm->pcm.pcm_id != SOF_WOV_PCM_ID) | ||
| continue; | ||
|
|
Add SOF_IPC4_NOTIFY_PHRASE_DETECTED notification handler, sent by DSP FW when a keyword is detected by WoV pipeline. Handler parses PCM list to find WoV capture PCM pcm_id 11, calls snd_sof_pcm_period_elapsed() to unblock waiting capture stream. Signed-off-by: Naveen Manohar <naveen.m@intel.com>
When DSP reports keyword detection, notify topology-defined WoV kcontrols so that user space can poll for value changes. Checked for 2 kcontrols in loaded topology: - 'wov_trigger_id': RO enum reporting winner slot(0/1/2) - 'wov_event': control that user space polls via POLLPRI Signed-off-by: Naveen Manohar <naveen.m@intel.com>
85f6bee to
a9f3678
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
sound/soc/sof/ipc4-wov.c:105
- The "PCM not found" warning can become noisy if firmware reports phrase detections while the WoV topology/PCM isn't present. Consider making this warning ratelimited to avoid log spam.
dev_warn(sdev->dev, "WoV: PHRASE_DETECTED but PCM %d not found\n",
SOF_WOV_PCM_ID);
| /* PCM ID for WoV keyword detection capture stream */ | ||
| #define SOF_WOV_PCM_ID 11 | ||
|
|
| if (!substream || !substream->runtime) { | ||
| dev_warn(sdev->dev, "WoV: PCM %d not open\n", | ||
| SOF_WOV_PCM_ID); | ||
| return; | ||
| } |
| pm_wakeup_event(sdev->dev, 2000); | ||
|
|
||
| list_for_each_entry(spcm, &sdev->pcm_list, list) { | ||
| if (le32_to_cpu(spcm->pcm.pcm_id) != SOF_WOV_PCM_ID) |
There was a problem hiding this comment.
This is ABI and will be enforced in all cases? not possible to have more than one PCM for WoV?
There was a problem hiding this comment.
No, PCM 11 is not intended to be generic IPC4 ABI, applicable only for WoV ref topology.
Proposed 3-KPD WoV reference topology has 1 shared capture pcm(ID 11) and firmware arbiter routes winning detector slot to it.
There was a problem hiding this comment.
We need to document it in the topology. So that people will not change the PCM ID in the topology in the future.
|
|
||
| kctl = snd_ctl_find_id(card, &id); | ||
| if (kctl) | ||
| snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_VALUE, kctl, 0); |
There was a problem hiding this comment.
what kind of controls are these?
They are coming from topology and attached to the module?
Why are you sending notification to two controls? and what user space can read out from them?
Where is the information?
If they are standard controls then why not use the standard kcontrol change notification for byte/enum/switch that we already have and leave this global one out, not handle it?
There was a problem hiding this comment.
wov_trigger_id is topology defined, read-only bytes control attached to WoV arbiter.
Proposal is Userspace reads it to obtain winning detector slot after a phrase detection.
https://intel-my.sharepoint.com/:u:/p/naveen_m/IQBikNrDbrDeSoBhGILQQ6YkAQCStNB7G9FX-n-r1gn0YlI?email=peter.ujfalusi%40intel.com&e=Lnesig
Add SOF_IPC4_NOTIFY_PHRASE_DETECTED notification handler for WoV.
When DSP FW reports keyword detection, unblock the WoV capture stream
via snd_pcm_period_elapsed()
Notify topology-defined kcontrols ('wov_trigger_id', 'wov_event') for userspace polling.
V2: snd_pcm_period_elapsed -> snd_sof_pcm_period_elapsed, word_id bit correction