Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ __cold static int mic_privacy_configure(struct processing_module *mod, struct co
{
struct mic_privacy_data *mic_priv_data;
atomic_val_t word;
int muted;
int ret;

assert_can_be_cold();
Expand All @@ -116,15 +117,19 @@ __cold static int mic_privacy_configure(struct processing_module *mod, struct co
cd->mic_priv = mic_priv_data;

/*
* Start from the current mic privacy state, which the DMIC IRQ enable
* above may just have posted, and take only the changes posted after it.
* Take only the mic privacy states posted from now on, and start from
* the current state: read it if this copier can, which is after the
* sequence number so that a change in between is taken at the next
* copy, else start from the last state posted.
*/
word = atomic_get(&mic_privacy_state_word);
mic_priv_data->state_seq = MIC_PRIV_STATE_SEQ(word);
if (MIC_PRIV_STATE_MUTE(word))
muted = mic_privacy_get_copier_mic_disable_status(cd->gtw_type == ipc4_gtw_dmic);
if (muted < 0)
muted = MIC_PRIV_STATE_MUTE(word);
Comment on lines +128 to +129

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in f07e754. With HW_MANAGED, a DMIC copier now posts the state it reads from DMICXPVCCS if it differs from the last state posted. The post is a compare-and-swap against the word read before the register, so it never overwrites a newer state that the DMIC interrupt posted in between. Non-DMIC copiers configured after it start from that state, and running copiers take it at their next copy.

With no DMIC DAI probed, there is nothing safe to read: DMICXPVCCS can't be accessed then, and the kernel only sends the SoundWire state on a change (sof_ptl_mic_privacy_work()). So a non-DMIC copier still starts from the last state posted, the same as before #11503. The mic data is still not exposed in that case: with HW_MANAGED, the hardware zeroes the DMA data of the links selected in DDZLS by itself after the DDZWT time-out. Only the copier's own fade is missing until the next change.

The always-on DFMICPVCS.MDIO (the privacy indicator output) could be a starting state with no DMIC. But the Zephyr driver has no getter for it, and its timing under HW_MANAGED needs checking on a device with that policy, so I've left it for a follow-up.

if (muted)
mic_priv_data->mic_privacy_state = MIC_PRIV_MUTED;
mic_priv_data->max_ramp_time_in_ms = (MIC_PRIV_STATE_RAMP(word) * 1000) /
ADSP_RTC_FREQUENCY;
mic_priv_data->max_ramp_time_in_ms = zeroing_wait_time;

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/audio/mic_privacy_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void mic_privacy_propagate_settings(struct mic_privacy_settings *settings);
uint32_t mic_privacy_get_dma_zeroing_wait_time(void);
uint32_t mic_privacy_get_privacy_mask(void);
uint32_t mic_privacy_get_mic_disable_status(void);
int mic_privacy_get_copier_mic_disable_status(bool dmic_gateway);
void mic_privacy_enable_dmic_irq(bool enable_irq);
void mic_privacy_fill_settings(struct mic_privacy_settings *settings, uint32_t mic_disable_status);
void mic_privacy_set_gtw_mic_state(struct mic_privacy_data *mic_priv_data,
Expand Down
52 changes: 40 additions & 12 deletions src/kernel/audio/mic_privacy_manager/mic_privacy_manager_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ __cold int mic_privacy_manager_init(void)
enable_fw_managed_irq(true);
}

/*
* Post the state at boot, including after D3, so that copiers configured
* before the first change start from it.
*/
if (mic_privacy_policy == MIC_PRIVACY_HW_MANAGED ||
mic_privacy_policy == MIC_PRIVACY_FW_MANAGED) {
struct mic_privacy_settings settings;

mic_privacy_fill_settings(&settings, mic_privacy_get_mic_disable_status());
mic_privacy_propagate_settings(&settings);
}

return 0;
}

Expand Down Expand Up @@ -283,6 +271,46 @@ void mic_privacy_process(struct comp_dev *dev, struct mic_privacy_data *mic_priv
}
}

/*
* The current mic disable state for a copier that configures mic privacy, or
* -ENODATA if the copier can not read it.
*
* With HW_MANAGED mic privacy, the state is in the DMIC registers, which are
* only powered and owned by the DSP once a DMIC DAI is probed, so only a DMIC
* copier, after it has created its DAI, can read it. The other copiers start
* from the last state posted, so a DMIC copier also posts the state it reads
* when that is not the last state posted, unless a state was posted while it
* read it.
*/
int mic_privacy_get_copier_mic_disable_status(bool dmic_gateway)
{
struct mic_privacy_settings settings;
uint32_t mic_disable_status;
atomic_val_t old;

switch (mic_privacy_policy) {
case MIC_PRIVACY_FW_MANAGED:
return mic_privacy_api->get_fw_managed_mic_disable_status() ? 1 : 0;
case MIC_PRIVACY_HW_MANAGED:
if (!dmic_gateway)
return -ENODATA;

old = atomic_get(&mic_privacy_state_word);
mic_disable_status = mic_privacy_api->get_dmic_mic_disable_status() ? 1 : 0;
if (mic_disable_status != MIC_PRIV_STATE_MUTE(old)) {
mic_privacy_fill_settings(&settings, mic_disable_status);
atomic_cas(&mic_privacy_state_word, old,
MIC_PRIV_STATE_WORD(MIC_PRIV_STATE_SEQ(old) + 1,
settings.mic_privacy_state,
settings.max_ramp_time));
}

return mic_disable_status;
default:
return -ENODATA;
}
}

uint32_t mic_privacy_get_mic_disable_status(void)
{
if (!mic_priv_dev) {
Expand Down
Loading