Skip to content

Commit

Permalink
ASoC: sof: ipc4-control: Force method for global capture hw mute indi…
Browse files Browse the repository at this point in the history
…cator

This is inteded for driving the mute indicator following dsp power
state. If dsp is powerred down the capture muted state should be
indicated.

Signed-off-by: Jyri Sarha <[email protected]>
  • Loading branch information
Jyri Sarha committed Jan 28, 2025
1 parent 15c3955 commit 50568cb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
42 changes: 34 additions & 8 deletions sound/soc/sof/ipc4-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,11 @@ sof_ipc4_set_up_volume_table(struct snd_sof_control *scontrol, int tlv[SOF_TLV_I

struct sof_ipc4_kcontrol_global_priv {
struct snd_card *snd_card;
struct snd_kcontrol *capture_hw_mute;
struct sof_ipc4_kcontrol_global_capture_hw_mute {
struct snd_kcontrol *kctl;
bool force_muted; /* If true mute state indicator forced to muted */
bool last_reported; /* The latest mute state received from FW */
} capture_hw_mute;
};

static int sof_ipc4_capture_hw_mute_get(struct snd_kcontrol *kcontrol,
Expand Down Expand Up @@ -920,10 +924,13 @@ static int sof_ipc4_create_non_topology_controls(struct snd_sof_dev *sdev,
kctl->private_value = 0;

ret = snd_ctl_add(snd_card, kctl);
if (ret < 0)
if (ret >= 0) {
priv->capture_hw_mute.kctl = kctl;
priv->capture_hw_mute.force_muted = false;
priv->capture_hw_mute.last_reported = false;
} else {
dev_err(dev, "%s: snd_ctl_add(): failed", __func__);
else
priv->capture_hw_mute = kctl;
}
}

ipc4_data->global_kcontrol_priv = priv;
Expand All @@ -939,13 +946,19 @@ static void snd_ipc4_global_capture_hw_mute_report(struct snd_sof_dev *sdev,
struct device *dev = sdev->dev;
struct snd_kcontrol *kctl;

if (!priv || !priv->capture_hw_mute)
if (!priv || !priv->capture_hw_mute.kctl)
return;

kctl = priv->capture_hw_mute;
kctl = priv->capture_hw_mute.kctl;

dev_dbg(dev, "%s: reporting %u, old %lu", __func__,
status, kctl->private_value);
dev_dbg(dev, "%s: new %u, old %lu, last %u force %u", __func__,
status, kctl->private_value, priv->capture_hw_mute.last_reported,
priv->capture_hw_mute.force_muted);

priv->capture_hw_mute.last_reported = status;

if (priv->capture_hw_mute.force_muted)
status = false;

if (kctl->private_value == status)
return;
Expand All @@ -954,6 +967,19 @@ static void snd_ipc4_global_capture_hw_mute_report(struct snd_sof_dev *sdev,
snd_ctl_notify(priv->snd_card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
}

void snd_ipc4_global_capture_hw_mute_force(struct snd_sof_dev *sdev, bool force)
{
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
struct sof_ipc4_kcontrol_global_priv *priv = ipc4_data->global_kcontrol_priv;

if (!priv)
return;

priv->capture_hw_mute.force_muted = force;

snd_ipc4_global_capture_hw_mute_report(sdev, priv->capture_hw_mute.last_reported);
}

static void snd_ipc4_handle_global_event(struct snd_sof_dev *sdev,
struct sof_ipc4_control_msg_payload *msg_data)
{
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/sof/ipc4-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,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 snd_ipc4_global_capture_hw_mute_force(struct snd_sof_dev *sdev, bool force);

#endif

0 comments on commit 50568cb

Please sign in to comment.