ASoC: SOF: Drop ipc_cmd parameter for snd_sof_ipc_set_get_comp_data()

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_IPC_COMP_*_DATA
otherwise SOF_IPC_COMP_*_VALUE.

The SET or GET direction can be selected with the use of `set` parameter.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20211215180404.53254-3-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Peter Ujfalusi 2021-12-15 10:03:58 -08:00 коммит произвёл Mark Brown
Родитель 9d562fdcd5
Коммит d4a06c4334
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
4 изменённых файлов: 11 добавлений и 19 удалений

Просмотреть файл

@ -69,7 +69,6 @@ static void snd_sof_refresh_control(struct snd_sof_control *scontrol)
{ {
struct sof_ipc_ctrl_data *cdata = scontrol->control_data; struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
struct snd_soc_component *scomp = scontrol->scomp; struct snd_soc_component *scomp = scontrol->scomp;
u32 ipc_cmd;
int ret; int ret;
if (!scontrol->comp_data_dirty) if (!scontrol->comp_data_dirty)
@ -78,18 +77,13 @@ static void snd_sof_refresh_control(struct snd_sof_control *scontrol)
if (!pm_runtime_active(scomp->dev)) if (!pm_runtime_active(scomp->dev))
return; return;
if (scontrol->cmd == SOF_CTRL_CMD_BINARY)
ipc_cmd = SOF_IPC_COMP_GET_DATA;
else
ipc_cmd = SOF_IPC_COMP_GET_VALUE;
/* set the ABI header values */ /* set the ABI header values */
cdata->data->magic = SOF_ABI_MAGIC; cdata->data->magic = SOF_ABI_MAGIC;
cdata->data->abi = SOF_ABI_VERSION; cdata->data->abi = SOF_ABI_VERSION;
/* refresh the component data from DSP */ /* refresh the component data from DSP */
scontrol->comp_data_dirty = false; scontrol->comp_data_dirty = false;
ret = snd_sof_ipc_set_get_comp_data(scontrol, ipc_cmd, ret = snd_sof_ipc_set_get_comp_data(scontrol,
SOF_CTRL_TYPE_VALUE_CHAN_GET, SOF_CTRL_TYPE_VALUE_CHAN_GET,
scontrol->cmd, false); scontrol->cmd, false);
if (ret < 0) { if (ret < 0) {
@ -143,7 +137,6 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol,
/* notify DSP of mixer updates */ /* notify DSP of mixer updates */
if (pm_runtime_active(scomp->dev)) if (pm_runtime_active(scomp->dev))
snd_sof_ipc_set_get_comp_data(scontrol, snd_sof_ipc_set_get_comp_data(scontrol,
SOF_IPC_COMP_SET_VALUE,
SOF_CTRL_TYPE_VALUE_CHAN_SET, SOF_CTRL_TYPE_VALUE_CHAN_SET,
SOF_CTRL_CMD_VOLUME, SOF_CTRL_CMD_VOLUME,
true); true);
@ -216,7 +209,6 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
/* notify DSP of mixer updates */ /* notify DSP of mixer updates */
if (pm_runtime_active(scomp->dev)) if (pm_runtime_active(scomp->dev))
snd_sof_ipc_set_get_comp_data(scontrol, snd_sof_ipc_set_get_comp_data(scontrol,
SOF_IPC_COMP_SET_VALUE,
SOF_CTRL_TYPE_VALUE_CHAN_SET, SOF_CTRL_TYPE_VALUE_CHAN_SET,
SOF_CTRL_CMD_SWITCH, SOF_CTRL_CMD_SWITCH,
true); true);
@ -265,7 +257,6 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
/* notify DSP of enum updates */ /* notify DSP of enum updates */
if (pm_runtime_active(scomp->dev)) if (pm_runtime_active(scomp->dev))
snd_sof_ipc_set_get_comp_data(scontrol, snd_sof_ipc_set_get_comp_data(scontrol,
SOF_IPC_COMP_SET_VALUE,
SOF_CTRL_TYPE_VALUE_CHAN_SET, SOF_CTRL_TYPE_VALUE_CHAN_SET,
SOF_CTRL_CMD_ENUM, SOF_CTRL_CMD_ENUM,
true); true);
@ -343,7 +334,6 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol,
/* notify DSP of byte control updates */ /* notify DSP of byte control updates */
if (pm_runtime_active(scomp->dev)) if (pm_runtime_active(scomp->dev))
snd_sof_ipc_set_get_comp_data(scontrol, snd_sof_ipc_set_get_comp_data(scontrol,
SOF_IPC_COMP_SET_DATA,
SOF_CTRL_TYPE_DATA_SET, SOF_CTRL_TYPE_DATA_SET,
scontrol->cmd, scontrol->cmd,
true); true);
@ -423,7 +413,6 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
/* notify DSP of byte control updates */ /* notify DSP of byte control updates */
if (pm_runtime_active(scomp->dev)) if (pm_runtime_active(scomp->dev))
snd_sof_ipc_set_get_comp_data(scontrol, snd_sof_ipc_set_get_comp_data(scontrol,
SOF_IPC_COMP_SET_DATA,
SOF_CTRL_TYPE_DATA_SET, SOF_CTRL_TYPE_DATA_SET,
scontrol->cmd, scontrol->cmd,
true); true);
@ -463,7 +452,7 @@ int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _
cdata->data->magic = SOF_ABI_MAGIC; cdata->data->magic = SOF_ABI_MAGIC;
cdata->data->abi = SOF_ABI_VERSION; cdata->data->abi = SOF_ABI_VERSION;
/* get all the component data from DSP */ /* get all the component data from DSP */
ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_GET_DATA, SOF_CTRL_TYPE_DATA_GET, ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_CTRL_TYPE_DATA_GET,
scontrol->cmd, false); scontrol->cmd, false);
if (ret < 0) if (ret < 0)
goto out; goto out;

Просмотреть файл

@ -817,7 +817,6 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
* IPC get()/set() for kcontrols. * IPC get()/set() for kcontrols.
*/ */
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
u32 ipc_cmd,
enum sof_ipc_ctrl_type ctrl_type, enum sof_ipc_ctrl_type ctrl_type,
enum sof_ipc_ctrl_cmd ctrl_cmd, bool set) enum sof_ipc_ctrl_cmd ctrl_cmd, bool set)
{ {
@ -830,6 +829,7 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
struct snd_sof_widget *swidget; struct snd_sof_widget *swidget;
bool widget_found = false; bool widget_found = false;
size_t send_bytes; size_t send_bytes;
u32 ipc_cmd;
int err; int err;
list_for_each_entry(swidget, &sdev->widget_list, list) { list_for_each_entry(swidget, &sdev->widget_list, list) {
@ -873,6 +873,12 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
return err; return err;
} }
/* Select the IPC cmd based on the ctrl_cmd and the direction */
if (ctrl_cmd == SOF_CTRL_CMD_BINARY)
ipc_cmd = set ? SOF_IPC_COMP_SET_DATA : SOF_IPC_COMP_GET_DATA;
else
ipc_cmd = set ? SOF_IPC_COMP_SET_VALUE : SOF_IPC_COMP_GET_VALUE;
cdata->rhdr.hdr.cmd = SOF_IPC_GLB_COMP_MSG | ipc_cmd; cdata->rhdr.hdr.cmd = SOF_IPC_GLB_COMP_MSG | ipc_cmd;
cdata->cmd = ctrl_cmd; cdata->cmd = ctrl_cmd;
cdata->type = ctrl_type; cdata->type = ctrl_type;

Просмотреть файл

@ -14,7 +14,7 @@
static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol) static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol)
{ {
int ipc_cmd, ctrl_type; enum sof_ipc_ctrl_type ctrl_type;
int ret; int ret;
/* reset readback offset for scontrol */ /* reset readback offset for scontrol */
@ -25,18 +25,16 @@ static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *
case SOF_CTRL_CMD_VOLUME: case SOF_CTRL_CMD_VOLUME:
case SOF_CTRL_CMD_ENUM: case SOF_CTRL_CMD_ENUM:
case SOF_CTRL_CMD_SWITCH: case SOF_CTRL_CMD_SWITCH:
ipc_cmd = SOF_IPC_COMP_SET_VALUE;
ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET; ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET;
break; break;
case SOF_CTRL_CMD_BINARY: case SOF_CTRL_CMD_BINARY:
ipc_cmd = SOF_IPC_COMP_SET_DATA;
ctrl_type = SOF_CTRL_TYPE_DATA_SET; ctrl_type = SOF_CTRL_TYPE_DATA_SET;
break; break;
default: default:
return 0; return 0;
} }
ret = snd_sof_ipc_set_get_comp_data(scontrol, ipc_cmd, ctrl_type, scontrol->cmd, true); ret = snd_sof_ipc_set_get_comp_data(scontrol, ctrl_type, scontrol->cmd, true);
if (ret < 0) if (ret < 0)
dev_err(sdev->dev, "error: failed kcontrol value set for widget: %d\n", dev_err(sdev->dev, "error: failed kcontrol value set for widget: %d\n",
scontrol->comp_id); scontrol->comp_id);

Просмотреть файл

@ -240,7 +240,6 @@ static inline void snd_sof_compr_init_elapsed_work(struct work_struct *work) { }
* Mixer IPC * Mixer IPC
*/ */
int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
u32 ipc_cmd,
enum sof_ipc_ctrl_type ctrl_type, enum sof_ipc_ctrl_type ctrl_type,
enum sof_ipc_ctrl_cmd ctrl_cmd, bool set); enum sof_ipc_ctrl_cmd ctrl_cmd, bool set);