Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: SOF: Intel: Add support for hardware mic privacy change reporting #5312

Open
wants to merge 8 commits into
base: topic/sof-dev
Choose a base branch
from
13 changes: 13 additions & 0 deletions include/sound/sof/ipc4/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ enum sof_ipc4_base_fw_params {
SOF_IPC4_FW_PARAM_MODULES_INFO_GET,
SOF_IPC4_FW_PARAM_LIBRARIES_INFO_GET = 16,
SOF_IPC4_FW_PARAM_SYSTEM_TIME = 20,
SOF_IPC4_FW_PARAM_MIC_PRIVACY_STATE_CHANGE = 35,
Copy link
Member

Choose a reason for hiding this comment

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

This is very controversial.
In the case of DMICs, the mute can be completely handled by firmware since it also processes the GPIO that toggles the privacy.
In the case of SoundWire, the mute is expected to be handled in the external codec.

In other words, this IPC does not seem to have a purpose other than academic - and it's mind-blowing that such a split implementation for a 'secure' solution relies on an IPC from the host. Recompile your kernel and the privacy is crippled... That does not sound good, does it.

};

enum sof_ipc4_fw_config_params {
Expand Down Expand Up @@ -446,6 +447,18 @@ struct sof_ipc4_dx_state_info {
uint32_t dx_mask;
} __packed __aligned(4);

enum sof_ipc4_hw_config_params {
SOF_IPC4_HW_CFG_INTEL_MIC_PRIVACY_CAPS = 11,
};

#define SOF_IPC_INTEL_MIC_PRIVACY_VERSION_PTL 1

struct sof_ipc4_intel_mic_privacy_cap {
uint32_t version;
uint32_t capabilities_length;
uint32_t capabilities[];
} __packed;

/* Reply messages */

/*
Expand Down
33 changes: 33 additions & 0 deletions sound/soc/sof/ipc4-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,39 @@ int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
offset += sizeof(*tuple) + tuple->size;
}

/* Get the hardware configuration */
msg.primary = SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG);
msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST);
msg.primary |= SOF_IPC4_MOD_ID(SOF_IPC4_MOD_INIT_BASEFW_MOD_ID);
msg.primary |= SOF_IPC4_MOD_INSTANCE(SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID);
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(SOF_IPC4_FW_PARAM_HW_CONFIG_GET);

msg.data_size = sdev->ipc->max_payload_size;

ret = iops->set_get_data(sdev, &msg, msg.data_size, false);
if (ret)
goto out;

offset = 0;
while (offset < msg.data_size) {
tuple = (struct sof_ipc4_tuple *)((u8 *)msg.data_ptr + offset);

switch (tuple->type) {
case SOF_IPC4_HW_CFG_INTEL_MIC_PRIVACY_CAPS:
if (ipc4_data->intel_configure_mic_privacy) {
struct sof_ipc4_intel_mic_privacy_cap *caps;

caps = (struct sof_ipc4_intel_mic_privacy_cap *)tuple->value;
ipc4_data->intel_configure_mic_privacy(sdev, caps);
}
break;
default:
break;
}

offset += sizeof(*tuple) + tuple->size;
}

out:
kfree(msg.data_ptr);

Expand Down
5 changes: 5 additions & 0 deletions sound/soc/sof/ipc4-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <linux/idr.h>
#include <sound/sof/ext_manifest4.h>
#include <sound/sof/ipc4/header.h>
#include "sof-priv.h"

/* The DSP window indices are fixed */
Expand Down Expand Up @@ -89,6 +90,8 @@ struct sof_ipc4_fw_data {

int (*load_library)(struct snd_sof_dev *sdev,
struct sof_ipc4_fw_library *fw_lib, bool reload);
void (*intel_configure_mic_privacy)(struct snd_sof_dev *sdev,
struct sof_ipc4_intel_mic_privacy_cap *caps);
struct mutex pipeline_state_mutex; /* protect pipeline triggers, ref counts and states */
};

Expand Down Expand Up @@ -118,4 +121,6 @@ void sof_ipc4_update_cpc_from_manifest(struct snd_sof_dev *sdev,
size_t sof_ipc4_find_debug_slot_offset_by_type(struct snd_sof_dev *sdev,
u32 slot_type);

void sof_ipc4_mic_privacy_state_change(struct snd_sof_dev *sdev, bool state);

#endif
18 changes: 18 additions & 0 deletions sound/soc/sof/ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,21 @@ const struct sof_ipc_ops ipc4_ops = {
.pcm = &ipc4_pcm_ops,
.fw_tracing = &ipc4_mtrace_ops,
};

void sof_ipc4_mic_privacy_state_change(struct snd_sof_dev *sdev, bool state)
{
struct sof_ipc4_msg msg;
u32 data = state;

msg.primary = SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG);
msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST);
msg.primary |= SOF_IPC4_MOD_ID(SOF_IPC4_MOD_INIT_BASEFW_MOD_ID);
msg.primary |= SOF_IPC4_MOD_INSTANCE(SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID);
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(SOF_IPC4_FW_PARAM_MIC_PRIVACY_STATE_CHANGE);

msg.data_size = sizeof(data);
msg.data_ptr = &data;

sof_ipc4_set_get_data(sdev, &msg, msg.data_size, true);
}
EXPORT_SYMBOL(sof_ipc4_mic_privacy_state_change);