Skip to content

Commit fc76ad3

Browse files
ujfalusiplbossart
authored andcommitted
ASoC: SOF: Drop ctrl_type parameter for snd_sof_ipc_set_get_comp_data()
The SOF_CTRL_TYPE_VALUE_COMP_* type is not used by the firmware nor in the kernel side. It is also not clear what action should be taken for such type. With this in mind: The correct ipc_cmd can be selected based on the `ctrl_cmd` and the `set` parameters: if the ctrl_cmd is SOF_CTRL_CMD_BINARY then SOF_CTRL_TYPE_DATA_* otherwise SOF_CTRL_TYPE_VALUE_CHAN_*. The SET or GET direction can be selected with the use of `set` parameter. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent b9e1284 commit fc76ad3

4 files changed

Lines changed: 22 additions & 48 deletions

File tree

sound/soc/sof/control.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ static void snd_sof_refresh_control(struct snd_sof_control *scontrol)
8383

8484
/* refresh the component data from DSP */
8585
scontrol->comp_data_dirty = false;
86-
ret = snd_sof_ipc_set_get_comp_data(scontrol,
87-
SOF_CTRL_TYPE_VALUE_CHAN_GET, false);
86+
ret = snd_sof_ipc_set_get_comp_data(scontrol, false);
8887
if (ret < 0) {
8988
dev_err(scomp->dev, "error: failed to get control data: %d\n", ret);
9089
/* Set the flag to re-try next time to get the data */
@@ -135,8 +134,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
135134

136135
/* notify DSP of mixer updates */
137136
if (pm_runtime_active(scomp->dev))
138-
snd_sof_ipc_set_get_comp_data(scontrol,
139-
SOF_CTRL_TYPE_VALUE_CHAN_SET, true);
137+
snd_sof_ipc_set_get_comp_data(scontrol, true);
140138
return change;
141139
}
142140

@@ -205,8 +203,7 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
205203

206204
/* notify DSP of mixer updates */
207205
if (pm_runtime_active(scomp->dev))
208-
snd_sof_ipc_set_get_comp_data(scontrol,
209-
SOF_CTRL_TYPE_VALUE_CHAN_SET, true);
206+
snd_sof_ipc_set_get_comp_data(scontrol, true);
210207

211208
return change;
212209
}
@@ -251,8 +248,7 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
251248

252249
/* notify DSP of enum updates */
253250
if (pm_runtime_active(scomp->dev))
254-
snd_sof_ipc_set_get_comp_data(scontrol,
255-
SOF_CTRL_TYPE_VALUE_CHAN_SET, true);
251+
snd_sof_ipc_set_get_comp_data(scontrol, true);
256252

257253
return change;
258254
}
@@ -326,8 +322,7 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
326322

327323
/* notify DSP of byte control updates */
328324
if (pm_runtime_active(scomp->dev))
329-
snd_sof_ipc_set_get_comp_data(scontrol,
330-
SOF_CTRL_TYPE_DATA_SET, true);
325+
snd_sof_ipc_set_get_comp_data(scontrol, true);
331326

332327
return 0;
333328
}
@@ -403,8 +398,7 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
403398

404399
/* notify DSP of byte control updates */
405400
if (pm_runtime_active(scomp->dev))
406-
snd_sof_ipc_set_get_comp_data(scontrol,
407-
SOF_CTRL_TYPE_DATA_SET, true);
401+
snd_sof_ipc_set_get_comp_data(scontrol, true);
408402

409403
return 0;
410404
}
@@ -441,7 +435,7 @@ int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _
441435
cdata->data->magic = SOF_ABI_MAGIC;
442436
cdata->data->abi = SOF_ABI_VERSION;
443437
/* get all the component data from DSP */
444-
ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_CTRL_TYPE_DATA_GET, false);
438+
ret = snd_sof_ipc_set_get_comp_data(scontrol, false);
445439
if (ret < 0)
446440
goto out;
447441

sound/soc/sof/ipc.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,6 @@ static int sof_get_ctrl_copy_params(enum sof_ipc_ctrl_type ctrl_type,
710710
sparams->src = (u8 *)src->chanv;
711711
sparams->dst = (u8 *)dst->chanv;
712712
break;
713-
case SOF_CTRL_TYPE_VALUE_COMP_GET:
714-
case SOF_CTRL_TYPE_VALUE_COMP_SET:
715-
sparams->src = (u8 *)src->compv;
716-
sparams->dst = (u8 *)dst->compv;
717-
break;
718713
case SOF_CTRL_TYPE_DATA_GET:
719714
case SOF_CTRL_TYPE_DATA_SET:
720715
sparams->src = (u8 *)src->data->data;
@@ -805,15 +800,15 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
805800
/*
806801
* IPC get()/set() for kcontrols.
807802
*/
808-
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
809-
enum sof_ipc_ctrl_type ctrl_type, bool set)
803+
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, bool set)
810804
{
811805
struct snd_soc_component *scomp = scontrol->scomp;
812806
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
813807
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
814808
struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
815809
struct sof_ipc_fw_version *v = &ready->version;
816810
struct sof_ipc_ctrl_data_params sparams;
811+
enum sof_ipc_ctrl_type ctrl_type;
817812
struct snd_sof_widget *swidget;
818813
bool widget_found = false;
819814
size_t send_bytes;
@@ -861,11 +856,19 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
861856
return err;
862857
}
863858

864-
/* Select the IPC cmd based on the ctrl_cmd and the direction */
865-
if (cdata->cmd == SOF_CTRL_CMD_BINARY)
859+
/*
860+
* Select the IPC cmd and the ctrl_type based on the ctrl_cmd and the
861+
* direction
862+
* Note: SOF_CTRL_TYPE_VALUE_COMP_* is not used and supported currently
863+
* for ctrl_type
864+
*/
865+
if (cdata->cmd == SOF_CTRL_CMD_BINARY) {
866866
ipc_cmd = set ? SOF_IPC_COMP_SET_DATA : SOF_IPC_COMP_GET_DATA;
867-
else
867+
ctrl_type = set ? SOF_CTRL_TYPE_DATA_SET : SOF_CTRL_TYPE_DATA_GET;
868+
} else {
868869
ipc_cmd = set ? SOF_IPC_COMP_SET_VALUE : SOF_IPC_COMP_GET_VALUE;
870+
ctrl_type = set ? SOF_CTRL_TYPE_VALUE_CHAN_SET : SOF_CTRL_TYPE_VALUE_CHAN_GET;
871+
}
869872

870873
cdata->rhdr.hdr.cmd = SOF_IPC_GLB_COMP_MSG | ipc_cmd;
871874
cdata->type = ctrl_type;
@@ -881,13 +884,6 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
881884
sparams.hdr_bytes = sizeof(struct sof_ipc_ctrl_data);
882885
sparams.elems = scontrol->num_channels;
883886
break;
884-
case SOF_CTRL_TYPE_VALUE_COMP_GET:
885-
case SOF_CTRL_TYPE_VALUE_COMP_SET:
886-
sparams.msg_bytes = scontrol->num_channels *
887-
sizeof(struct sof_ipc_ctrl_value_comp);
888-
sparams.hdr_bytes = sizeof(struct sof_ipc_ctrl_data);
889-
sparams.elems = scontrol->num_channels;
890-
break;
891887
case SOF_CTRL_TYPE_DATA_GET:
892888
case SOF_CTRL_TYPE_DATA_SET:
893889
sparams.msg_bytes = cdata->data->size;

sound/soc/sof/sof-audio.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,12 @@
1414

1515
static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
1616
{
17-
enum sof_ipc_ctrl_type ctrl_type;
1817
int ret;
1918

2019
/* reset readback offset for scontrol */
2120
scontrol->readback_offset = 0;
2221

23-
/* notify DSP of kcontrol values */
24-
switch (scontrol->control_data->cmd) {
25-
case SOF_CTRL_CMD_VOLUME:
26-
case SOF_CTRL_CMD_ENUM:
27-
case SOF_CTRL_CMD_SWITCH:
28-
ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET;
29-
break;
30-
case SOF_CTRL_CMD_BINARY:
31-
ctrl_type = SOF_CTRL_TYPE_DATA_SET;
32-
break;
33-
default:
34-
return 0;
35-
}
36-
37-
ret = snd_sof_ipc_set_get_comp_data(scontrol, ctrl_type, true);
22+
ret = snd_sof_ipc_set_get_comp_data(scontrol, true);
3823
if (ret < 0)
3924
dev_err(sdev->dev, "error: failed kcontrol value set for widget: %d\n",
4025
scontrol->comp_id);

sound/soc/sof/sof-audio.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ static inline void snd_sof_compr_init_elapsed_work(struct work_struct *work) { }
238238
/*
239239
* Mixer IPC
240240
*/
241-
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
242-
enum sof_ipc_ctrl_type ctrl_type, bool set);
241+
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, bool set);
243242

244243
/* DAI link fixup */
245244
int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);

0 commit comments

Comments
 (0)