Skip to content

Commit 5b606a9

Browse files
ranj063lgirdwood
authored andcommitted
tools: plugin: ctl: Add a helper function to configure the IPC message
This will avoid the duplicated code when configuring the IPC message for kcontrol IO. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 5416adb commit 5b606a9

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

  • tools/plugin/alsaplug

tools/plugin/alsaplug/ctl.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,20 @@ static int plug_ctl_get_integer_info(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
198198
return err;
199199
}
200200

201+
static void plug_ctl_ipc_message(struct ipc4_module_large_config *config, int param_id,
202+
size_t size, uint32_t module_id, uint32_t instance_id,
203+
uint32_t type)
204+
{
205+
config->primary.r.type = type;
206+
config->primary.r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_MODULE_MSG;
207+
config->primary.r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
208+
config->primary.r.module_id = module_id;
209+
config->primary.r.instance_id = instance_id;
210+
211+
config->extension.r.data_off_size = size;
212+
config->extension.r.large_param_id = param_id;
213+
}
214+
201215
static int plug_ctl_read_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value)
202216
{
203217
snd_sof_ctl_t *ctl = ext->private_data;
@@ -212,14 +226,9 @@ static int plug_ctl_read_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long
212226
int i, err;
213227

214228
/* configure the IPC message */
215-
config.primary.r.type = SOF_IPC4_MOD_LARGE_CONFIG_GET;
216-
config.primary.r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_MODULE_MSG;
217-
config.primary.r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
218-
config.primary.r.module_id = ctl->glb->ctl[key].module_id;
219-
config.primary.r.instance_id = ctl->glb->ctl[key].instance_id;
220-
221-
config.extension.r.data_off_size = sizeof(volume);
222-
config.extension.r.large_param_id = IPC4_VOLUME;
229+
plug_ctl_ipc_message(&config, IPC4_VOLUME, sizeof(volume), ctl->glb->ctl[key].module_id,
230+
ctl->glb->ctl[key].instance_id, SOF_IPC4_MOD_LARGE_CONFIG_GET);
231+
223232
config.extension.r.final_block = 1;
224233
config.extension.r.init_block = 1;
225234

@@ -316,14 +325,9 @@ static int plug_ctl_write_integer(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, lon
316325
volume.curve_duration = 200000;
317326

318327
/* configure the IPC message */
319-
config.primary.r.type = SOF_IPC4_MOD_LARGE_CONFIG_SET;
320-
config.primary.r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_MODULE_MSG;
321-
config.primary.r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST;
322-
config.primary.r.module_id = ctl->glb->ctl[key].module_id;
323-
config.primary.r.instance_id = ctl->glb->ctl[key].instance_id;
324-
325-
config.extension.r.data_off_size = sizeof(volume);
326-
config.extension.r.large_param_id = IPC4_VOLUME;
328+
plug_ctl_ipc_message(&config, IPC4_VOLUME, sizeof(volume),
329+
ctl->glb->ctl[key].module_id, ctl->glb->ctl[key].instance_id,
330+
SOF_IPC4_MOD_LARGE_CONFIG_SET);
327331
config.extension.r.final_block = 1;
328332
config.extension.r.init_block = 1;
329333

0 commit comments

Comments
 (0)