Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200908092825.1813847-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Dharageswari R and committed by
Mark Brown
783560d0 819b9f60

+64
+3
include/uapi/sound/sof/tokens.h
··· 24 24 #define SOF_TPLG_KCTL_ENUM_ID 257 25 25 #define SOF_TPLG_KCTL_BYTES_ID 258 26 26 #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 27 30 28 31 /* 29 32 * Tokens - must match values in topology configurations
+58
sound/soc/sof/control.c
··· 353 353 return 0; 354 354 } 355 355 356 + int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data, 357 + unsigned int size) 358 + { 359 + struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value; 360 + struct snd_sof_control *scontrol = be->dobj.private; 361 + struct snd_soc_component *scomp = scontrol->scomp; 362 + struct sof_ipc_ctrl_data *cdata = scontrol->control_data; 363 + struct snd_ctl_tlv header; 364 + struct snd_ctl_tlv __user *tlvd = (struct snd_ctl_tlv __user *)binary_data; 365 + size_t data_size; 366 + int ret; 367 + int err; 368 + 369 + ret = pm_runtime_get_sync(scomp->dev); 370 + if (ret < 0) { 371 + dev_err_ratelimited(scomp->dev, "error: bytes_ext get failed to resume %d\n", ret); 372 + pm_runtime_put_noidle(scomp->dev); 373 + return ret; 374 + } 375 + 376 + /* set the ABI header values */ 377 + cdata->data->magic = SOF_ABI_MAGIC; 378 + cdata->data->abi = SOF_ABI_VERSION; 379 + /* get all the component data from DSP */ 380 + ret = snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_GET_DATA, SOF_CTRL_TYPE_DATA_GET, 381 + scontrol->cmd, false); 382 + if (ret < 0) 383 + goto out; 384 + 385 + /* check data size doesn't exceed max coming from topology */ 386 + if (cdata->data->size > be->max - sizeof(const struct sof_abi_hdr)) { 387 + dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %zu.\n", 388 + cdata->data->size, 389 + 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 + 356 414 int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, 357 415 unsigned int __user *binary_data, 358 416 unsigned int size)
+2
sound/soc/sof/sof-audio.h
··· 142 142 int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, 143 143 unsigned int __user *binary_data, 144 144 unsigned int size); 145 + int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int __user *binary_data, 146 + unsigned int size); 145 147 146 148 /* 147 149 * Topology.
+1
sound/soc/sof/topology.c
··· 3688 3688 /* vendor specific bytes ext handlers available for binding */ 3689 3689 static const struct snd_soc_tplg_bytes_ext_ops sof_bytes_ext_ops[] = { 3690 3690 {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}, 3691 3692 }; 3692 3693 3693 3694 static struct snd_soc_tplg_ops sof_tplg_ops = {