Skip to content

Commit 33fd4f9

Browse files
Dharageswari Rplbossart
authored andcommitted
ASoC: SOF: Implement snd_sof_bytes_ext_volatile_get kcontrol IO
This patch implements the snd_sof_bytes_ext_volatile_get() to read the actual parameters from DSP by sending the SOF_IPC_COMP_GET_DATA IPC for the kcontrol of type SOF_TPLG_KCTL_BYTES_VOLATILE_RO. Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
1 parent 38d7853 commit 33fd4f9

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

include/uapi/sound/sof/tokens.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#define SOF_TPLG_KCTL_ENUM_ID 257
2525
#define SOF_TPLG_KCTL_BYTES_ID 258
2626
#define SOF_TPLG_KCTL_SWITCH_ID 259
27+
#define SOF_TPLG_KCTL_BYTES_VOLATILE_RO 260
28+
#define SOF_TPLG_KCTL_BYTES_VOLATILE_RW 261
29+
#define SOF_TPLG_KCTL_BYTES_WO_ID 262
2730

2831
/*
2932
* Tokens - must match values in topology configurations

sound/soc/sof/control.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,64 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
353353
return 0;
354354
}
355355

356+
357+
int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data,
358+
unsigned int size)
359+
{
360+
struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value;
361+
struct snd_sof_control *scontrol = be->dobj.private;
362+
struct snd_soc_component *scomp = scontrol->scomp;
363+
struct sof_ipc_ctrl_data *cdata = scontrol->control_data;
364+
struct snd_ctl_tlv header;
365+
struct snd_ctl_tlv __user *tlvd = (struct snd_ctl_tlv __user *)binary_data;
366+
size_t data_size;
367+
int ret;
368+
int err;
369+
370+
ret = pm_runtime_get_sync(scomp->dev);
371+
if (ret < 0) {
372+
dev_err_ratelimited(scomp->dev, "error: bytes_ext get failed to resume %d\n", ret);
373+
pm_runtime_put_noidle(scomp->dev);
374+
return ret;
375+
}
376+
377+
/* set the ABI header values */
378+
cdata->data->magic = SOF_ABI_MAGIC;
379+
cdata->data->abi = SOF_ABI_VERSION;
380+
/* get all the component data from DSP */
381+
ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_GET_DATA, SOF_CTRL_TYPE_DATA_GET,
382+
scontrol->cmd, false);
383+
if (ret < 0)
384+
goto out;
385+
386+
/* check data size doesn't exceed max coming from topology */
387+
if (cdata->data->size > be->max - sizeof(const struct sof_abi_hdr)) {
388+
dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %lu.\n",
389+
cdata->data->size, be->max - sizeof(const struct sof_abi_hdr));
390+
ret = -EINVAL;
391+
goto out;
392+
}
393+
394+
data_size = cdata->data->size + sizeof(const struct sof_abi_hdr);
395+
396+
header.numid = scontrol->cmd;
397+
header.length = data_size;
398+
if (copy_to_user(tlvd, &header, sizeof(const struct snd_ctl_tlv))) {
399+
ret = -EFAULT;
400+
goto out;
401+
}
402+
403+
if (copy_to_user(tlvd->tlv, cdata->data, data_size))
404+
ret = -EFAULT;
405+
out:
406+
pm_runtime_mark_last_busy(scomp->dev);
407+
err = pm_runtime_put_autosuspend(scomp->dev);
408+
if (err < 0)
409+
dev_err_ratelimited(scomp->dev, "error: bytes_ext get failed to idle %d\n", err);
410+
411+
return ret;
412+
}
413+
356414
int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
357415
unsigned int __user *binary_data,
358416
unsigned int size)

sound/soc/sof/sof-audio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol,
142142
int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol,
143143
unsigned int __user *binary_data,
144144
unsigned int size);
145+
int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data,
146+
unsigned int size);
145147

146148
/*
147149
* Topology.

sound/soc/sof/topology.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3688,6 +3688,7 @@ static const struct snd_soc_tplg_kcontrol_ops sof_io_ops[] = {
36883688
/* vendor specific bytes ext handlers available for binding */
36893689
static const struct snd_soc_tplg_bytes_ext_ops sof_bytes_ext_ops[] = {
36903690
{SOF_TPLG_KCTL_BYTES_ID, snd_sof_bytes_ext_get, snd_sof_bytes_ext_put},
3691+
{SOF_TPLG_KCTL_BYTES_VOLATILE_RO, snd_sof_bytes_ext_volatile_get},
36913692
};
36923693

36933694
static struct snd_soc_tplg_ops sof_tplg_ops = {

0 commit comments

Comments
 (0)