Skip to content

Commit 50568cb

Browse files
author
Jyri Sarha
committed
ASoC: sof: ipc4-control: Force method for global capture hw mute indicator
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]>
1 parent 15c3955 commit 50568cb

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

sound/soc/sof/ipc4-control.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,11 @@ sof_ipc4_set_up_volume_table(struct snd_sof_control *scontrol, int tlv[SOF_TLV_I
854854

855855
struct sof_ipc4_kcontrol_global_priv {
856856
struct snd_card *snd_card;
857-
struct snd_kcontrol *capture_hw_mute;
857+
struct sof_ipc4_kcontrol_global_capture_hw_mute {
858+
struct snd_kcontrol *kctl;
859+
bool force_muted; /* If true mute state indicator forced to muted */
860+
bool last_reported; /* The latest mute state received from FW */
861+
} capture_hw_mute;
858862
};
859863

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

922926
ret = snd_ctl_add(snd_card, kctl);
923-
if (ret < 0)
927+
if (ret >= 0) {
928+
priv->capture_hw_mute.kctl = kctl;
929+
priv->capture_hw_mute.force_muted = false;
930+
priv->capture_hw_mute.last_reported = false;
931+
} else {
924932
dev_err(dev, "%s: snd_ctl_add(): failed", __func__);
925-
else
926-
priv->capture_hw_mute = kctl;
933+
}
927934
}
928935

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

942-
if (!priv || !priv->capture_hw_mute)
949+
if (!priv || !priv->capture_hw_mute.kctl)
943950
return;
944951

945-
kctl = priv->capture_hw_mute;
952+
kctl = priv->capture_hw_mute.kctl;
946953

947-
dev_dbg(dev, "%s: reporting %u, old %lu", __func__,
948-
status, kctl->private_value);
954+
dev_dbg(dev, "%s: new %u, old %lu, last %u force %u", __func__,
955+
status, kctl->private_value, priv->capture_hw_mute.last_reported,
956+
priv->capture_hw_mute.force_muted);
957+
958+
priv->capture_hw_mute.last_reported = status;
959+
960+
if (priv->capture_hw_mute.force_muted)
961+
status = false;
949962

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

970+
void snd_ipc4_global_capture_hw_mute_force(struct snd_sof_dev *sdev, bool force)
971+
{
972+
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
973+
struct sof_ipc4_kcontrol_global_priv *priv = ipc4_data->global_kcontrol_priv;
974+
975+
if (!priv)
976+
return;
977+
978+
priv->capture_hw_mute.force_muted = force;
979+
980+
snd_ipc4_global_capture_hw_mute_report(sdev, priv->capture_hw_mute.last_reported);
981+
}
982+
957983
static void snd_ipc4_handle_global_event(struct snd_sof_dev *sdev,
958984
struct sof_ipc4_control_msg_payload *msg_data)
959985
{

sound/soc/sof/ipc4-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,6 @@ void sof_ipc4_update_cpc_from_manifest(struct snd_sof_dev *sdev,
119119
size_t sof_ipc4_find_debug_slot_offset_by_type(struct snd_sof_dev *sdev,
120120
u32 slot_type);
121121

122+
void snd_ipc4_global_capture_hw_mute_force(struct snd_sof_dev *sdev, bool force);
123+
122124
#endif

0 commit comments

Comments
 (0)