summaryrefslogtreecommitdiffstats
path: root/sound/soc/sof
diff options
context:
space:
mode:
authorDragos Tarcatu <dragos_tarcatu@mentor.com>2019-10-18 08:38:06 -0400
committerMark Brown <broonie@kernel.org>2019-10-18 13:09:22 -0400
commit95a32c98055f664f9b3f34c41e153d4dcedd0eff (patch)
treef9ba57e41470ab30bac5ee3a67af6a714b2cb5ef /sound/soc/sof
parent9b7a7f921689d6c254e5acd670be631ebd82d54d (diff)
ASoC: SOF: control: return true when kcontrol values change
All the kcontrol put() functions are currently returning 0 when successful. This does not go well with alsamixer as it does not seem to get notified on SND_CTL_EVENT_MASK_VALUE callbacks when values change for (some of) the sof kcontrols. This patch fixes that by returning true for volume, switch and enum type kcontrols when values do change in put(). Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20191018123806.18063-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof')
-rw-r--r--sound/soc/sof/control.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index a4983f90ff5b..2b8711eda362 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -60,13 +60,16 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
60 struct snd_sof_dev *sdev = scontrol->sdev; 60 struct snd_sof_dev *sdev = scontrol->sdev;
61 struct sof_ipc_ctrl_data *cdata = scontrol->control_data; 61 struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
62 unsigned int i, channels = scontrol->num_channels; 62 unsigned int i, channels = scontrol->num_channels;
63 bool change = false;
64 u32 value;
63 65
64 /* update each channel */ 66 /* update each channel */
65 for (i = 0; i < channels; i++) { 67 for (i = 0; i < channels; i++) {
66 cdata->chanv[i].value = 68 value = mixer_to_ipc(ucontrol->value.integer.value[i],
67 mixer_to_ipc(ucontrol->value.integer.value[i],
68 scontrol->volume_table, sm->max + 1); 69 scontrol->volume_table, sm->max + 1);
70 change = change || (value != cdata->chanv[i].value);
69 cdata->chanv[i].channel = i; 71 cdata->chanv[i].channel = i;
72 cdata->chanv[i].value = value;
70 } 73 }
71 74
72 /* notify DSP of mixer updates */ 75 /* notify DSP of mixer updates */
@@ -76,8 +79,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
76 SOF_CTRL_TYPE_VALUE_CHAN_GET, 79 SOF_CTRL_TYPE_VALUE_CHAN_GET,
77 SOF_CTRL_CMD_VOLUME, 80 SOF_CTRL_CMD_VOLUME,
78 true); 81 true);
79 82 return change;
80 return 0;
81} 83}
82 84
83int snd_sof_switch_get(struct snd_kcontrol *kcontrol, 85int snd_sof_switch_get(struct snd_kcontrol *kcontrol,
@@ -105,11 +107,15 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
105 struct snd_sof_dev *sdev = scontrol->sdev; 107 struct snd_sof_dev *sdev = scontrol->sdev;
106 struct sof_ipc_ctrl_data *cdata = scontrol->control_data; 108 struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
107 unsigned int i, channels = scontrol->num_channels; 109 unsigned int i, channels = scontrol->num_channels;
110 bool change = false;
111 u32 value;
108 112
109 /* update each channel */ 113 /* update each channel */
110 for (i = 0; i < channels; i++) { 114 for (i = 0; i < channels; i++) {
111 cdata->chanv[i].value = ucontrol->value.integer.value[i]; 115 value = ucontrol->value.integer.value[i];
116 change = change || (value != cdata->chanv[i].value);
112 cdata->chanv[i].channel = i; 117 cdata->chanv[i].channel = i;
118 cdata->chanv[i].value = value;
113 } 119 }
114 120
115 /* notify DSP of mixer updates */ 121 /* notify DSP of mixer updates */
@@ -120,7 +126,7 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
120 SOF_CTRL_CMD_SWITCH, 126 SOF_CTRL_CMD_SWITCH,
121 true); 127 true);
122 128
123 return 0; 129 return change;
124} 130}
125 131
126int snd_sof_enum_get(struct snd_kcontrol *kcontrol, 132int snd_sof_enum_get(struct snd_kcontrol *kcontrol,
@@ -148,11 +154,15 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
148 struct snd_sof_dev *sdev = scontrol->sdev; 154 struct snd_sof_dev *sdev = scontrol->sdev;
149 struct sof_ipc_ctrl_data *cdata = scontrol->control_data; 155 struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
150 unsigned int i, channels = scontrol->num_channels; 156 unsigned int i, channels = scontrol->num_channels;
157 bool change = false;
158 u32 value;
151 159
152 /* update each channel */ 160 /* update each channel */
153 for (i = 0; i < channels; i++) { 161 for (i = 0; i < channels; i++) {
154 cdata->chanv[i].value = ucontrol->value.enumerated.item[i]; 162 value = ucontrol->value.enumerated.item[i];
163 change = change || (value != cdata->chanv[i].value);
155 cdata->chanv[i].channel = i; 164 cdata->chanv[i].channel = i;
165 cdata->chanv[i].value = value;
156 } 166 }
157 167
158 /* notify DSP of enum updates */ 168 /* notify DSP of enum updates */
@@ -163,7 +173,7 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
163 SOF_CTRL_CMD_ENUM, 173 SOF_CTRL_CMD_ENUM,
164 true); 174 true);
165 175
166 return 0; 176 return change;
167} 177}
168 178
169int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, 179int snd_sof_bytes_get(struct snd_kcontrol *kcontrol,