Skip to content

Conversation

@tmleman
Copy link
Contributor

@tmleman tmleman commented May 28, 2025

This PR fixes two issues with the microphone privacy feature during D3 state transitions:

  1. Re-establishes proper microphone privacy functionality after D3 resume by:

    • Re-initializing the mic_privacy_manager in the resume_dais() function
    • Restoring privacy settings after D3 transitions
    • Re-enabling privacy IRQ handlers to ensure continued operation
  2. Eliminates unwanted fade effect in audio when resuming from D3 with privacy enabled by:

    • Force setting mic_privacy_state to MUTED without fade effects

These changes ensure microphone privacy works reliably through power state transitions and correctly mutes audio without any fade artifacts when privacy is enabled.

Copilot AI review requested due to automatic review settings May 28, 2025 11:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request addresses two issues with the microphone privacy feature during D3 transitions by re-establishing correct state handling on resume and eliminating unwanted audio fade effects.

  • Re-initializes the mic privacy manager and saves/restores privacy settings during D3 transitions.
  • Eliminates fade effects by forcefully setting the mic privacy state to MUTED in the resume routine.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
zephyr/lib/cpu.c Updates state handling for mic privacy during D3 suspend/resume and re-enables IRQs post-resume.
src/audio/mic_privacy_manager/mic_privacy_manager_intel.c Enhances DMIC IRQ handling and restores settings during initialization after D3 transitions.

@kv2019i kv2019i added this to the v2.13 milestone May 28, 2025
@tmleman tmleman force-pushed the topic/upstream/pr/fix/pm/mic_privacy branch 2 times, most recently from adbcf54 to d10c58f Compare May 28, 2025 12:12
@tmleman tmleman requested a review from Copilot May 28, 2025 12:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issues with microphone privacy during D3 state transitions by re-establishing proper privacy settings and eliminating fade artifacts during resume. Key changes include re-initializing the mic privacy manager on resume, restoring MIC privacy settings without fade effects, and updating the DMIC IRQ handling logic.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
zephyr/lib/cpu.c Added logic to save and restore MIC privacy settings during D3.
src/audio/mic_privacy_manager/mic_privacy_manager_intel.c Enhanced IRQ handling by adding device/API checks and adjusting disable logic.
Comments suppressed due to low confidence (1)

src/audio/mic_privacy_manager/mic_privacy_manager_intel.c:85

  • When disabling the DMIC IRQ, if get_dmic_irq_status() returns false, there is no call to explicitly disable the IRQ. Consider adding a call to mic_privacy_api->enable_dmic_irq(false, NULL) to ensure the IRQ is disabled in all cases.
else { /* Check current status immediately to handle any transitions during D3 */

@tmleman tmleman force-pushed the topic/upstream/pr/fix/pm/mic_privacy branch from d10c58f to 9b52ed5 Compare May 28, 2025 12:20
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.

Some minor notes, but no blockers.

/* Ensure we're starting from a clean state with no fade effects */
if (cd->mic_priv->mic_privacy_state) {
/* Force immediate mute without fade effect */
cd->mic_priv->mic_privacy_state = MIC_PRIV_MUTED;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if FW went to D3 during fade in? Previous state was MIC_PRIV_FADE_IN, expected to be unmuted soon, but here we force mute. there will be state mismatch. I recommend reading mic state directly from HW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fragment is only intended to eliminate the fade-out effect. In the case when mic privacy was turned off during D3, fade-in is still present (at least that's how the audio behaves in the test).

@tmleman tmleman force-pushed the topic/upstream/pr/fix/pm/mic_privacy branch from 9b52ed5 to faf7a3b Compare May 29, 2025 08:03
else

/* Check current status immediately to handle any transitions during D3 */
if (mic_privacy_api->get_dmic_irq_status()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have interrupts disabled at cpu level 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.

Yes

When resuming from D3 state, the microphone privacy feature wasn't
properly restored, causing two critical issues:

1. The system didn't respond to privacy button inputs after D3
   transitions
2. A short fade-out effect appeared in audio when privacy was enabled,
   causing test failures that expected complete silence

This patch provides a comprehensive solution by:
- Adding mic_privacy_manager_init() to resume_dais() to ensure proper
  re-initialization of the microphone privacy subsystem after D3
- Implementing mic_privacy_get_mic_disable_status() to correctly
  retrieve the current microphone disable status
- Storing the mic_disable_status before entering D3 and comparing it
  after resume to detect changes during low power state
- Enhancing mic_privacy_enable_dmic_irq() to immediately check for IRQ
  status after D3 transitions to catch events that occurred during
  suspended state
- Explicitly resetting fade parameters (fade_in_out_bytes, gain
  parameters) to ensure immediate silence without fade artifacts when
  privacy is enabled
- Adding proper error handling and validation to ensure the mic_priv
  structure is valid before access

With these changes, the microphone privacy feature works correctly
through power state transitions and properly mutes audio without fade
artifacts when privacy is enabled after D3 resume.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@tmleman tmleman force-pushed the topic/upstream/pr/fix/pm/mic_privacy branch from faf7a3b to 9479454 Compare May 29, 2025 22:13
@tmleman tmleman requested a review from abonislawski May 29, 2025 22:22
@tmleman tmleman requested review from mbukowsk and softwarecki May 29, 2025 22:22
@lgirdwood lgirdwood merged commit aea8101 into thesofproject:main May 30, 2025
42 of 48 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.

6 participants