Skip to content

Commit c3c09ea

Browse files
committed
ASoC: SOF: Intel: ptl: Move the IPC sending to be done in a work
IPC message cannot be sent from the irq thread directly. Use the sof_intel_hda_dev level mic privacy struct to delay the notification sending. Fixes: 4a43c32 ("ASoC: SOF: Intel: ptl: Add support for mic privacy") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 7c0f7d3 commit c3c09ea

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

sound/soc/sof/intel/ptl.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,44 @@ static bool sof_ptl_check_mic_privacy_irq(struct snd_sof_dev *sdev, bool alt,
2727
return hdac_bus_eml_is_mic_privacy_changed(sof_to_bus(sdev), alt, elid);
2828
}
2929

30+
static void sof_ptl_mic_privacy_work(struct work_struct *work)
31+
{
32+
struct sof_intel_hda_dev *hdev = container_of(work,
33+
struct sof_intel_hda_dev,
34+
mic_privacy.work);
35+
struct hdac_bus *bus = &hdev->hbus.core;
36+
struct snd_sof_dev *sdev = dev_get_drvdata(bus->dev);
37+
bool state;
38+
39+
/*
40+
* The microphone privacy state is only available via Soundwire shim
41+
* in PTL
42+
* The work is only scheduled on change.
43+
*/
44+
state = hdac_bus_eml_get_mic_privacy_state(bus, 1,
45+
AZX_REG_ML_LEPTR_ID_SDW);
46+
sof_ipc4_mic_privacy_state_change(sdev, state);
47+
}
48+
3049
static void sof_ptl_process_mic_privacy(struct snd_sof_dev *sdev, bool alt,
3150
int elid)
3251
{
33-
bool state;
52+
struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
3453

3554
if (!alt || elid != AZX_REG_ML_LEPTR_ID_SDW)
3655
return;
3756

38-
state = hdac_bus_eml_get_mic_privacy_state(sof_to_bus(sdev), alt, elid);
39-
40-
sof_ipc4_mic_privacy_state_change(sdev, state);
57+
/*
58+
* Schedule the work to read the microphone privacy state and send IPC
59+
* message about the new state to the firmware
60+
*/
61+
schedule_work(&hdev->mic_privacy.work);
4162
}
4263

4364
static void sof_ptl_set_mic_privacy(struct snd_sof_dev *sdev,
4465
struct sof_ipc4_intel_mic_privacy_cap *caps)
4566
{
67+
struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
4668
u32 micpvcp;
4769

4870
if (!caps || !caps->capabilities_length)
@@ -58,6 +80,9 @@ static void sof_ptl_set_mic_privacy(struct snd_sof_dev *sdev,
5880
hdac_bus_eml_set_mic_privacy_mask(sof_to_bus(sdev), true,
5981
AZX_REG_ML_LEPTR_ID_SDW,
6082
PTL_MICPVCP_GET_SDW_MASK(micpvcp));
83+
84+
INIT_WORK(&hdev->mic_privacy.work, sof_ptl_mic_privacy_work);
85+
hdev->mic_privacy.active = true;
6186
}
6287

6388
int sof_ptl_set_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *dsp_ops)

0 commit comments

Comments
 (0)