Lines Matching +full:data +full:- +full:size

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
10 #include "sof-priv.h"
11 #include "sof-audio.h"
12 #include "ipc4-priv.h"
13 #include "ipc4-topology.h"
18 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_set_get_kcontrol_data()
19 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_set_get_kcontrol_data()
21 const struct sof_ipc_ops *iops = sdev->ipc->ops; in sof_ipc4_set_get_kcontrol_data()
22 struct sof_ipc4_msg *msg = &cdata->msg; in sof_ipc4_set_get_kcontrol_data()
28 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc4_set_get_kcontrol_data()
29 if (swidget->comp_id == scontrol->comp_id) { in sof_ipc4_set_get_kcontrol_data()
36 dev_err(scomp->dev, "Failed to find widget for kcontrol %s\n", scontrol->name); in sof_ipc4_set_get_kcontrol_data()
37 return -ENOENT; in sof_ipc4_set_get_kcontrol_data()
41 mutex_lock(&swidget->setup_mutex); in sof_ipc4_set_get_kcontrol_data()
43 lockdep_assert_held(&swidget->setup_mutex); in sof_ipc4_set_get_kcontrol_data()
50 if (!swidget->use_count) in sof_ipc4_set_get_kcontrol_data()
53 msg->primary &= ~SOF_IPC4_MOD_INSTANCE_MASK; in sof_ipc4_set_get_kcontrol_data()
54 msg->primary |= SOF_IPC4_MOD_INSTANCE(swidget->instance_id); in sof_ipc4_set_get_kcontrol_data()
56 ret = iops->set_get_data(sdev, msg, msg->data_size, set); in sof_ipc4_set_get_kcontrol_data()
60 /* It is a set-data operation, and we have a valid backup that we can restore */ in sof_ipc4_set_get_kcontrol_data()
62 if (!scontrol->old_ipc_control_data) in sof_ipc4_set_get_kcontrol_data()
68 memcpy(scontrol->ipc_control_data, scontrol->old_ipc_control_data, in sof_ipc4_set_get_kcontrol_data()
69 scontrol->max_size); in sof_ipc4_set_get_kcontrol_data()
70 kfree(scontrol->old_ipc_control_data); in sof_ipc4_set_get_kcontrol_data()
71 scontrol->old_ipc_control_data = NULL; in sof_ipc4_set_get_kcontrol_data()
73 ret = iops->set_get_data(sdev, msg, msg->data_size, set); in sof_ipc4_set_get_kcontrol_data()
80 mutex_unlock(&swidget->setup_mutex); in sof_ipc4_set_get_kcontrol_data()
89 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_set_volume_data()
90 struct sof_ipc4_gain *gain = swidget->private; in sof_ipc4_set_volume_data()
91 struct sof_ipc4_msg *msg = &cdata->msg; in sof_ipc4_set_volume_data()
98 value = cdata->chanv[0].value; in sof_ipc4_set_volume_data()
99 for (i = 1; i < scontrol->num_channels; i++) { in sof_ipc4_set_volume_data()
100 if (cdata->chanv[i].value != value) { in sof_ipc4_set_volume_data()
110 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc4_set_volume_data()
113 params.init_val = cdata->chanv[0].value; in sof_ipc4_set_volume_data()
115 params.channels = cdata->chanv[i].channel; in sof_ipc4_set_volume_data()
116 params.init_val = cdata->chanv[i].value; in sof_ipc4_set_volume_data()
120 params.curve_duration_l = gain->data.params.curve_duration_l; in sof_ipc4_set_volume_data()
121 params.curve_duration_h = gain->data.params.curve_duration_h; in sof_ipc4_set_volume_data()
122 params.curve_type = gain->data.params.curve_type; in sof_ipc4_set_volume_data()
124 msg->data_ptr = &params; in sof_ipc4_set_volume_data()
125 msg->data_size = sizeof(params); in sof_ipc4_set_volume_data()
128 msg->data_ptr = NULL; in sof_ipc4_set_volume_data()
129 msg->data_size = 0; in sof_ipc4_set_volume_data()
131 dev_err(sdev->dev, "Failed to set volume update for %s\n", in sof_ipc4_set_volume_data()
132 scontrol->name); in sof_ipc4_set_volume_data()
146 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_volume_put()
147 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_volume_put()
149 unsigned int channels = scontrol->num_channels; in sof_ipc4_volume_put()
158 u32 value = mixer_to_ipc(ucontrol->value.integer.value[i], in sof_ipc4_volume_put()
159 scontrol->volume_table, scontrol->max + 1); in sof_ipc4_volume_put()
161 change = change || (value != cdata->chanv[i].value); in sof_ipc4_volume_put()
162 cdata->chanv[i].channel = i; in sof_ipc4_volume_put()
163 cdata->chanv[i].value = value; in sof_ipc4_volume_put()
166 if (!pm_runtime_active(scomp->dev)) in sof_ipc4_volume_put()
170 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc4_volume_put()
171 if (swidget->comp_id == scontrol->comp_id) { in sof_ipc4_volume_put()
178 dev_err(scomp->dev, "Failed to find widget for kcontrol %s\n", scontrol->name); in sof_ipc4_volume_put()
192 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_volume_get()
193 unsigned int channels = scontrol->num_channels; in sof_ipc4_volume_get()
197 ucontrol->value.integer.value[i] = ipc_to_mixer(cdata->chanv[i].value, in sof_ipc4_volume_get()
198 scontrol->volume_table, in sof_ipc4_volume_get()
199 scontrol->max + 1); in sof_ipc4_volume_get()
209 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_set_generic_control_data()
210 struct sof_ipc4_control_msg_payload *data; in sof_ipc4_set_generic_control_data() local
211 struct sof_ipc4_msg *msg = &cdata->msg; in sof_ipc4_set_generic_control_data()
216 data_size = struct_size(data, chanv, scontrol->num_channels); in sof_ipc4_set_generic_control_data()
217 data = kzalloc(data_size, GFP_KERNEL); in sof_ipc4_set_generic_control_data()
218 if (!data) in sof_ipc4_set_generic_control_data()
219 return -ENOMEM; in sof_ipc4_set_generic_control_data()
221 data->id = cdata->index; in sof_ipc4_set_generic_control_data()
222 data->num_elems = scontrol->num_channels; in sof_ipc4_set_generic_control_data()
223 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc4_set_generic_control_data()
224 data->chanv[i].channel = cdata->chanv[i].channel; in sof_ipc4_set_generic_control_data()
225 data->chanv[i].value = cdata->chanv[i].value; in sof_ipc4_set_generic_control_data()
228 msg->data_ptr = data; in sof_ipc4_set_generic_control_data()
229 msg->data_size = data_size; in sof_ipc4_set_generic_control_data()
232 msg->data_ptr = NULL; in sof_ipc4_set_generic_control_data()
233 msg->data_size = 0; in sof_ipc4_set_generic_control_data()
235 dev_err(sdev->dev, "Failed to set control update for %s\n", in sof_ipc4_set_generic_control_data()
236 scontrol->name); in sof_ipc4_set_generic_control_data()
238 kfree(data); in sof_ipc4_set_generic_control_data()
245 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_refresh_generic_control()
246 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_refresh_generic_control()
247 struct sof_ipc4_control_msg_payload *data; in sof_ipc4_refresh_generic_control() local
248 struct sof_ipc4_msg *msg = &cdata->msg; in sof_ipc4_refresh_generic_control()
253 if (!scontrol->comp_data_dirty) in sof_ipc4_refresh_generic_control()
256 if (!pm_runtime_active(scomp->dev)) in sof_ipc4_refresh_generic_control()
259 data_size = struct_size(data, chanv, scontrol->num_channels); in sof_ipc4_refresh_generic_control()
260 data = kmalloc(data_size, GFP_KERNEL); in sof_ipc4_refresh_generic_control()
261 if (!data) in sof_ipc4_refresh_generic_control()
264 data->id = cdata->index; in sof_ipc4_refresh_generic_control()
265 data->num_elems = scontrol->num_channels; in sof_ipc4_refresh_generic_control()
266 msg->data_ptr = data; in sof_ipc4_refresh_generic_control()
267 msg->data_size = data_size; in sof_ipc4_refresh_generic_control()
269 scontrol->comp_data_dirty = false; in sof_ipc4_refresh_generic_control()
271 msg->data_ptr = NULL; in sof_ipc4_refresh_generic_control()
272 msg->data_size = 0; in sof_ipc4_refresh_generic_control()
274 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc4_refresh_generic_control()
275 cdata->chanv[i].channel = data->chanv[i].channel; in sof_ipc4_refresh_generic_control()
276 cdata->chanv[i].value = data->chanv[i].value; in sof_ipc4_refresh_generic_control()
279 dev_err(scomp->dev, "Failed to read control data for %s\n", in sof_ipc4_refresh_generic_control()
280 scontrol->name); in sof_ipc4_refresh_generic_control()
281 scontrol->comp_data_dirty = true; in sof_ipc4_refresh_generic_control()
284 kfree(data); in sof_ipc4_refresh_generic_control()
290 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_switch_put()
291 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_switch_put()
301 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc4_switch_put()
302 value = ucontrol->value.integer.value[i]; in sof_ipc4_switch_put()
303 change = change || (value != cdata->chanv[i].value); in sof_ipc4_switch_put()
304 cdata->chanv[i].channel = i; in sof_ipc4_switch_put()
305 cdata->chanv[i].value = value; in sof_ipc4_switch_put()
308 if (!pm_runtime_active(scomp->dev)) in sof_ipc4_switch_put()
312 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc4_switch_put()
313 if (swidget->comp_id == scontrol->comp_id) { in sof_ipc4_switch_put()
320 dev_err(scomp->dev, "Failed to find widget for kcontrol %s\n", scontrol->name); in sof_ipc4_switch_put()
334 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_switch_get()
340 for (i = 0; i < scontrol->num_channels; i++) in sof_ipc4_switch_get()
341 ucontrol->value.integer.value[i] = cdata->chanv[i].value; in sof_ipc4_switch_get()
349 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_enum_put()
350 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_enum_put()
360 for (i = 0; i < scontrol->num_channels; i++) { in sof_ipc4_enum_put()
361 value = ucontrol->value.enumerated.item[i]; in sof_ipc4_enum_put()
362 change = change || (value != cdata->chanv[i].value); in sof_ipc4_enum_put()
363 cdata->chanv[i].channel = i; in sof_ipc4_enum_put()
364 cdata->chanv[i].value = value; in sof_ipc4_enum_put()
367 if (!pm_runtime_active(scomp->dev)) in sof_ipc4_enum_put()
371 list_for_each_entry(swidget, &sdev->widget_list, list) { in sof_ipc4_enum_put()
372 if (swidget->comp_id == scontrol->comp_id) { in sof_ipc4_enum_put()
379 dev_err(scomp->dev, "Failed to find widget for kcontrol %s\n", scontrol->name); in sof_ipc4_enum_put()
393 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_enum_get()
399 for (i = 0; i < scontrol->num_channels; i++) in sof_ipc4_enum_get()
400 ucontrol->value.enumerated.item[i] = cdata->chanv[i].value; in sof_ipc4_enum_get()
409 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_set_get_bytes_data()
410 struct sof_abi_hdr *data = cdata->data; in sof_ipc4_set_get_bytes_data() local
411 struct sof_ipc4_msg *msg = &cdata->msg; in sof_ipc4_set_get_bytes_data()
414 /* Send the new data to the firmware only if it is powered up */ in sof_ipc4_set_get_bytes_data()
415 if (set && !pm_runtime_active(sdev->dev)) in sof_ipc4_set_get_bytes_data()
418 msg->extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(data->type); in sof_ipc4_set_get_bytes_data()
420 msg->data_ptr = data->data; in sof_ipc4_set_get_bytes_data()
421 msg->data_size = data->size; in sof_ipc4_set_get_bytes_data()
425 dev_err(sdev->dev, "Failed to %s for %s\n", in sof_ipc4_set_get_bytes_data()
427 scontrol->name); in sof_ipc4_set_get_bytes_data()
429 msg->data_ptr = NULL; in sof_ipc4_set_get_bytes_data()
430 msg->data_size = 0; in sof_ipc4_set_get_bytes_data()
438 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_bytes_put()
439 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_bytes_put()
441 struct sof_abi_hdr *data = cdata->data; in sof_ipc4_bytes_put() local
442 size_t size; in sof_ipc4_bytes_put() local
444 if (scontrol->max_size > sizeof(ucontrol->value.bytes.data)) { in sof_ipc4_bytes_put()
445 dev_err_ratelimited(scomp->dev, in sof_ipc4_bytes_put()
446 "data max %zu exceeds ucontrol data array size\n", in sof_ipc4_bytes_put()
447 scontrol->max_size); in sof_ipc4_bytes_put()
448 return -EINVAL; in sof_ipc4_bytes_put()
451 /* scontrol->max_size has been verified to be >= sizeof(struct sof_abi_hdr) */ in sof_ipc4_bytes_put()
452 if (data->size > scontrol->max_size - sizeof(*data)) { in sof_ipc4_bytes_put()
453 dev_err_ratelimited(scomp->dev, in sof_ipc4_bytes_put()
454 "data size too big %u bytes max is %zu\n", in sof_ipc4_bytes_put()
455 data->size, scontrol->max_size - sizeof(*data)); in sof_ipc4_bytes_put()
456 return -EINVAL; in sof_ipc4_bytes_put()
459 size = data->size + sizeof(*data); in sof_ipc4_bytes_put()
462 memcpy(data, ucontrol->value.bytes.data, size); in sof_ipc4_bytes_put()
472 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_bytes_get()
473 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_bytes_get()
474 struct sof_abi_hdr *data = cdata->data; in sof_ipc4_bytes_get() local
475 size_t size; in sof_ipc4_bytes_get() local
477 if (scontrol->max_size > sizeof(ucontrol->value.bytes.data)) { in sof_ipc4_bytes_get()
478 dev_err_ratelimited(scomp->dev, "data max %zu exceeds ucontrol data array size\n", in sof_ipc4_bytes_get()
479 scontrol->max_size); in sof_ipc4_bytes_get()
480 return -EINVAL; in sof_ipc4_bytes_get()
483 if (data->size > scontrol->max_size - sizeof(*data)) { in sof_ipc4_bytes_get()
484 dev_err_ratelimited(scomp->dev, in sof_ipc4_bytes_get()
485 "%u bytes of control data is invalid, max is %zu\n", in sof_ipc4_bytes_get()
486 data->size, scontrol->max_size - sizeof(*data)); in sof_ipc4_bytes_get()
487 return -EINVAL; in sof_ipc4_bytes_get()
490 size = data->size + sizeof(*data); in sof_ipc4_bytes_get()
493 memcpy(ucontrol->value.bytes.data, data, size); in sof_ipc4_bytes_get()
500 unsigned int size) in sof_ipc4_bytes_ext_put() argument
503 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in sof_ipc4_bytes_ext_put()
504 struct snd_soc_component *scomp = scontrol->scomp; in sof_ipc4_bytes_ext_put()
506 struct sof_abi_hdr *data = cdata->data; in sof_ipc4_bytes_ext_put() local
511 * The beginning of bytes data contains a header from where in sof_ipc4_bytes_ext_put()
513 * length of data from tlvd->tlv. in sof_ipc4_bytes_ext_put()
516 return -EFAULT; in sof_ipc4_bytes_ext_put()
519 if (header.length + sizeof(struct snd_ctl_tlv) > size) { in sof_ipc4_bytes_ext_put()
520 dev_err_ratelimited(scomp->dev, in sof_ipc4_bytes_ext_put()
521 "Inconsistent TLV, data %d + header %zu > %d\n", in sof_ipc4_bytes_ext_put()
522 header.length, sizeof(struct snd_ctl_tlv), size); in sof_ipc4_bytes_ext_put()
523 return -EINVAL; in sof_ipc4_bytes_ext_put()
526 /* be->max is coming from topology */ in sof_ipc4_bytes_ext_put()
527 if (header.length > scontrol->max_size) { in sof_ipc4_bytes_ext_put()
528 dev_err_ratelimited(scomp->dev, in sof_ipc4_bytes_ext_put()
529 "Bytes data size %d exceeds max %zu\n", in sof_ipc4_bytes_ext_put()
530 header.length, scontrol->max_size); in sof_ipc4_bytes_ext_put()
531 return -EINVAL; in sof_ipc4_bytes_ext_put()
535 if (copy_from_user(&abi_hdr, tlvd->tlv, sizeof(abi_hdr))) in sof_ipc4_bytes_ext_put()
536 return -EFAULT; in sof_ipc4_bytes_ext_put()
539 dev_err_ratelimited(scomp->dev, "Wrong ABI magic 0x%08x\n", in sof_ipc4_bytes_ext_put()
541 return -EINVAL; in sof_ipc4_bytes_ext_put()
544 if (abi_hdr.size > scontrol->max_size - sizeof(abi_hdr)) { in sof_ipc4_bytes_ext_put()
545 dev_err_ratelimited(scomp->dev, in sof_ipc4_bytes_ext_put()
546 "%u bytes of control data is invalid, max is %zu\n", in sof_ipc4_bytes_ext_put()
547 abi_hdr.size, scontrol->max_size - sizeof(abi_hdr)); in sof_ipc4_bytes_ext_put()
548 return -EINVAL; in sof_ipc4_bytes_ext_put()
551 if (!scontrol->old_ipc_control_data) { in sof_ipc4_bytes_ext_put()
553 scontrol->old_ipc_control_data = kmemdup(scontrol->ipc_control_data, in sof_ipc4_bytes_ext_put()
554 scontrol->max_size, GFP_KERNEL); in sof_ipc4_bytes_ext_put()
555 if (!scontrol->old_ipc_control_data) in sof_ipc4_bytes_ext_put()
556 return -ENOMEM; in sof_ipc4_bytes_ext_put()
559 /* Copy the whole binary data which includes the ABI header and the payload */ in sof_ipc4_bytes_ext_put()
560 if (copy_from_user(data, tlvd->tlv, header.length)) { in sof_ipc4_bytes_ext_put()
561 memcpy(scontrol->ipc_control_data, scontrol->old_ipc_control_data, in sof_ipc4_bytes_ext_put()
562 scontrol->max_size); in sof_ipc4_bytes_ext_put()
563 kfree(scontrol->old_ipc_control_data); in sof_ipc4_bytes_ext_put()
564 scontrol->old_ipc_control_data = NULL; in sof_ipc4_bytes_ext_put()
565 return -EFAULT; in sof_ipc4_bytes_ext_put()
573 unsigned int size, bool from_dsp) in _sof_ipc4_bytes_ext_get() argument
576 struct sof_ipc4_control_data *cdata = scontrol->ipc_control_data; in _sof_ipc4_bytes_ext_get()
577 struct snd_soc_component *scomp = scontrol->scomp; in _sof_ipc4_bytes_ext_get()
578 struct sof_abi_hdr *data = cdata->data; in _sof_ipc4_bytes_ext_get() local
583 * Decrement the limit by ext bytes header size to ensure the user space in _sof_ipc4_bytes_ext_get()
586 if (size < sizeof(struct snd_ctl_tlv)) in _sof_ipc4_bytes_ext_get()
587 return -ENOSPC; in _sof_ipc4_bytes_ext_get()
589 size -= sizeof(struct snd_ctl_tlv); in _sof_ipc4_bytes_ext_get()
591 /* get all the component data from DSP */ in _sof_ipc4_bytes_ext_get()
600 data->magic = SOF_IPC4_ABI_MAGIC; in _sof_ipc4_bytes_ext_get()
603 if (data->size > scontrol->max_size - sizeof(*data)) { in _sof_ipc4_bytes_ext_get()
604 dev_err_ratelimited(scomp->dev, in _sof_ipc4_bytes_ext_get()
605 "%u bytes of control data is invalid, max is %zu\n", in _sof_ipc4_bytes_ext_get()
606 data->size, scontrol->max_size - sizeof(*data)); in _sof_ipc4_bytes_ext_get()
607 return -EINVAL; in _sof_ipc4_bytes_ext_get()
610 data_size = data->size + sizeof(struct sof_abi_hdr); in _sof_ipc4_bytes_ext_get()
612 /* make sure we don't exceed size provided by user space for data */ in _sof_ipc4_bytes_ext_get()
613 if (data_size > size) in _sof_ipc4_bytes_ext_get()
614 return -ENOSPC; in _sof_ipc4_bytes_ext_get()
616 header.numid = scontrol->comp_id; in _sof_ipc4_bytes_ext_get()
620 return -EFAULT; in _sof_ipc4_bytes_ext_get()
622 if (copy_to_user(tlvd->tlv, data, data_size)) in _sof_ipc4_bytes_ext_get()
623 return -EFAULT; in _sof_ipc4_bytes_ext_get()
630 unsigned int size) in sof_ipc4_bytes_ext_get() argument
632 return _sof_ipc4_bytes_ext_get(scontrol, binary_data, size, false); in sof_ipc4_bytes_ext_get()
637 unsigned int size) in sof_ipc4_bytes_ext_volatile_get() argument
639 return _sof_ipc4_bytes_ext_get(scontrol, binary_data, size, true); in sof_ipc4_bytes_ext_volatile_get()
646 if (scontrol->max == 1) in sof_ipc4_volsw_setup()
658 struct sof_ipc4_notify_module_data *ndata = ipc4_msg->data_ptr; in sof_ipc4_control_update()
669 if (ndata->event_data_size < sizeof(*msg_data)) { in sof_ipc4_control_update()
670 dev_err(sdev->dev, in sof_ipc4_control_update()
671 "%s: Invalid event data size for module %u.%u: %u\n", in sof_ipc4_control_update()
672 __func__, ndata->module_id, ndata->instance_id, in sof_ipc4_control_update()
673 ndata->event_data_size); in sof_ipc4_control_update()
677 event_param_id = ndata->event_id & SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_PARAMID_MASK; in sof_ipc4_control_update()
686 dev_err(sdev->dev, in sof_ipc4_control_update()
688 __func__, ndata->module_id, ndata->instance_id, in sof_ipc4_control_update()
693 /* Find the swidget based on ndata->module_id and ndata->instance_id */ in sof_ipc4_control_update()
694 swidget = sof_ipc4_find_swidget_by_ids(sdev, ndata->module_id, in sof_ipc4_control_update()
695 ndata->instance_id); in sof_ipc4_control_update()
697 dev_err(sdev->dev, "%s: Failed to find widget for module %u.%u\n", in sof_ipc4_control_update()
698 __func__, ndata->module_id, ndata->instance_id); in sof_ipc4_control_update()
703 msg_data = (struct sof_ipc4_control_msg_payload *)ndata->event_data; in sof_ipc4_control_update()
704 list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { in sof_ipc4_control_update()
705 if (scontrol->comp_id == swidget->comp_id) { in sof_ipc4_control_update()
708 cdata = scontrol->ipc_control_data; in sof_ipc4_control_update()
713 local_param_id = PARAM_ID_FROM_EXTENSION(cdata->msg.extension); in sof_ipc4_control_update()
715 msg_data->id == cdata->index) { in sof_ipc4_control_update()
723 dev_err(sdev->dev, in sof_ipc4_control_update()
725 __func__, swidget->widget->name, ndata->event_id & 0xffff, in sof_ipc4_control_update()
726 msg_data->id); in sof_ipc4_control_update()
730 if (msg_data->num_elems) { in sof_ipc4_control_update()
732 * The message includes the updated value/data, update the in sof_ipc4_control_update()
735 for (i = 0; i < msg_data->num_elems; i++) { in sof_ipc4_control_update()
736 u32 channel = msg_data->chanv[i].channel; in sof_ipc4_control_update()
738 if (channel >= scontrol->num_channels) { in sof_ipc4_control_update()
739 dev_warn(sdev->dev, in sof_ipc4_control_update()
741 scontrol->name, i); in sof_ipc4_control_update()
747 scontrol->comp_data_dirty = true; in sof_ipc4_control_update()
751 cdata->chanv[channel].value = msg_data->chanv[i].value; in sof_ipc4_control_update()
755 * Mark the scontrol as dirty because the value/data is changed in sof_ipc4_control_update()
758 scontrol->comp_data_dirty = true; in sof_ipc4_control_update()
765 widget = swidget->widget; in sof_ipc4_control_update()
766 for (i = 0; i < widget->num_kcontrols; i++) { in sof_ipc4_control_update()
768 if (widget->dobj.widget.kcontrol_type[i] == type && in sof_ipc4_control_update()
769 widget->kcontrol_news[i].index == cdata->index) { in sof_ipc4_control_update()
770 kc = widget->kcontrols[i]; in sof_ipc4_control_update()
778 snd_ctl_notify_one(swidget->scomp->card->snd_card, in sof_ipc4_control_update()
788 list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { in sof_ipc4_widget_kcontrol_setup()
789 if (scontrol->comp_id == swidget->comp_id) { in sof_ipc4_widget_kcontrol_setup()
790 switch (scontrol->info_type) { in sof_ipc4_widget_kcontrol_setup()
810 dev_err(sdev->dev, in sof_ipc4_widget_kcontrol_setup()
812 scontrol->comp_id, swidget->widget->name); in sof_ipc4_widget_kcontrol_setup()
822 sof_ipc4_set_up_volume_table(struct snd_sof_control *scontrol, int tlv[SOF_TLV_ITEMS], int size) in sof_ipc4_set_up_volume_table() argument
827 scontrol->volume_table = kcalloc(size, sizeof(u32), GFP_KERNEL); in sof_ipc4_set_up_volume_table()
828 if (!scontrol->volume_table) in sof_ipc4_set_up_volume_table()
829 return -ENOMEM; in sof_ipc4_set_up_volume_table()
832 for (i = 0; i < size ; i++) { in sof_ipc4_set_up_volume_table()
836 scontrol->volume_table[i] = q31val > SOF_IPC4_VOL_ZERO_DB ? in sof_ipc4_set_up_volume_table()