Lines Matching +full:group +full:- +full:index +full:- +full:shift

1 // SPDX-License-Identifier: GPL-2.0
7 * https://www.mipi.org/mipi-sdca-v1-0-download
30 #include <sound/soc-component.h>
31 #include <sound/soc-dai.h>
32 #include <sound/soc-dapm.h>
37 switch (SDCA_CTL_TYPE(entity->type, control->sel)) { in exported_control()
44 return control->layers & (SDCA_ACCESS_LAYER_USER | in exported_control()
50 return control->has_fixed || control->mode == SDCA_ACCESS_MODE_RO; in readonly_control()
54 * sdca_asoc_count_component - count the various component parts
78 *num_widgets = function->num_entities - 1; in sdca_asoc_count_component()
83 for (i = 0; i < function->num_entities - 1; i++) { in sdca_asoc_count_component()
84 struct sdca_entity *entity = &function->entities[i]; in sdca_asoc_count_component()
87 switch (entity->type) { in sdca_asoc_count_component()
90 *num_routes += !!entity->iot.clock; in sdca_asoc_count_component()
91 *num_routes += !!entity->iot.is_dataport; in sdca_asoc_count_component()
92 *num_controls += !entity->iot.is_dataport; in sdca_asoc_count_component()
93 *num_dais += !!entity->iot.is_dataport; in sdca_asoc_count_component()
96 *num_routes += entity->pde.num_managed; in sdca_asoc_count_component()
102 if (entity->group) in sdca_asoc_count_component()
106 *num_routes += entity->num_sources; in sdca_asoc_count_component()
108 for (j = 0; j < entity->num_controls; j++) { in sdca_asoc_count_component()
109 if (exported_control(entity, &entity->controls[j])) in sdca_asoc_count_component()
177 return -EINVAL; in entity_early_parse_ge()
179 if (control->layers != SDCA_ACCESS_LAYER_CLASS) in entity_early_parse_ge()
181 entity->label, control->layers); in entity_early_parse_ge()
185 return -EINVAL; in entity_early_parse_ge()
188 entity->label, control->label); in entity_early_parse_ge()
190 return -ENOMEM; in entity_early_parse_ge()
194 return -ENOMEM; in entity_early_parse_ge()
198 return -ENOMEM; in entity_early_parse_ge()
200 texts = devm_kcalloc(dev, range->rows + 3, sizeof(*texts), GFP_KERNEL); in entity_early_parse_ge()
202 return -ENOMEM; in entity_early_parse_ge()
204 values = devm_kcalloc(dev, range->rows + 3, sizeof(*values), GFP_KERNEL); in entity_early_parse_ge()
206 return -ENOMEM; in entity_early_parse_ge()
214 for (i = 0; i < range->rows; i++) { in entity_early_parse_ge()
223 entity->label, type); in entity_early_parse_ge()
224 return -EINVAL; in entity_early_parse_ge()
228 soc_enum->reg = SDW_SDCA_CTL(function->desc->adr, entity->id, control->sel, 0); in entity_early_parse_ge()
229 soc_enum->items = range->rows + 3; in entity_early_parse_ge()
230 soc_enum->mask = roundup_pow_of_two(soc_enum->items) - 1; in entity_early_parse_ge()
231 soc_enum->texts = texts; in entity_early_parse_ge()
232 soc_enum->values = values; in entity_early_parse_ge()
234 kctl->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in entity_early_parse_ge()
235 kctl->name = control_name; in entity_early_parse_ge()
236 kctl->info = snd_soc_info_enum_double; in entity_early_parse_ge()
237 kctl->get = snd_soc_dapm_get_enum_double; in entity_early_parse_ge()
238 kctl->put = snd_soc_dapm_put_enum_double; in entity_early_parse_ge()
239 kctl->private_value = (unsigned long)soc_enum; in entity_early_parse_ge()
241 entity->ge.kctl = kctl; in entity_early_parse_ge()
249 (*route)->sink = sink; in add_route()
250 (*route)->control = control; in add_route()
251 (*route)->source = source; in add_route()
264 (*widget)->id = id; in entity_parse_simple()
267 for (i = 0; i < entity->num_sources; i++) in entity_parse_simple()
268 add_route(route, entity->label, NULL, entity->sources[i]->label); in entity_parse_simple()
281 if (entity->iot.is_dataport) { in entity_parse_it()
283 entity->label, "Playback"); in entity_parse_it()
285 return -ENOMEM; in entity_parse_it()
287 (*widget)->id = snd_soc_dapm_aif_in; in entity_parse_it()
289 add_route(route, entity->label, NULL, aif_name); in entity_parse_it()
291 (*widget)->id = snd_soc_dapm_mic; in entity_parse_it()
294 if (entity->iot.clock) in entity_parse_it()
295 add_route(route, entity->label, NULL, entity->iot.clock->label); in entity_parse_it()
297 for (i = 0; i < entity->num_sources; i++) in entity_parse_it()
298 add_route(route, entity->label, NULL, entity->sources[i]->label); in entity_parse_it()
313 if (entity->iot.is_dataport) { in entity_parse_ot()
315 entity->label, "Capture"); in entity_parse_ot()
317 return -ENOMEM; in entity_parse_ot()
319 (*widget)->id = snd_soc_dapm_aif_out; in entity_parse_ot()
321 add_route(route, aif_name, NULL, entity->label); in entity_parse_ot()
323 (*widget)->id = snd_soc_dapm_spk; in entity_parse_ot()
326 if (entity->iot.clock) in entity_parse_ot()
327 add_route(route, entity->label, NULL, entity->iot.clock->label); in entity_parse_ot()
329 for (i = 0; i < entity->num_sources; i++) in entity_parse_ot()
330 add_route(route, entity->label, NULL, entity->sources[i]->label); in entity_parse_ot()
340 struct snd_soc_component *component = widget->dapm->component; in entity_pde_event()
341 struct sdca_entity *entity = widget->priv; in entity_pde_event()
349 return -EIO; in entity_pde_event()
353 from = widget->on_val; in entity_pde_event()
354 to = widget->off_val; in entity_pde_event()
357 from = widget->off_val; in entity_pde_event()
358 to = widget->on_val; in entity_pde_event()
364 for (i = 0; i < entity->pde.num_max_delay; i++) { in entity_pde_event()
365 struct sdca_pde_delay *delay = &entity->pde.max_delay[i]; in entity_pde_event()
367 if (delay->from_ps == from && delay->to_ps == to) { in entity_pde_event()
368 poll_us = delay->us / polls; in entity_pde_event()
373 reg = SDW_SDCA_CTL(SDW_SDCA_CTL_FUNC(widget->reg), in entity_pde_event()
374 SDW_SDCA_CTL_ENT(widget->reg), in entity_pde_event()
381 ret = regmap_read(component->regmap, reg, &val); in entity_pde_event()
388 dev_err(component->dev, "%s: power transition failed: %x\n", in entity_pde_event()
389 entity->label, val); in entity_pde_event()
390 return -ETIMEDOUT; in entity_pde_event()
407 return -EINVAL; in entity_parse_pde()
410 if (control->layers != SDCA_ACCESS_LAYER_CLASS) in entity_parse_pde()
412 entity->label, control->layers); in entity_parse_pde()
416 return -EINVAL; in entity_parse_pde()
418 for (i = 0; i < range->rows; i++) in entity_parse_pde()
422 dev_err(dev, "%s: power control missing states\n", entity->label); in entity_parse_pde()
423 return -EINVAL; in entity_parse_pde()
426 (*widget)->id = snd_soc_dapm_supply; in entity_parse_pde()
427 (*widget)->reg = SDW_SDCA_CTL(function->desc->adr, entity->id, control->sel, 0); in entity_parse_pde()
428 (*widget)->mask = GENMASK(control->nbits - 1, 0); in entity_parse_pde()
429 (*widget)->on_val = SDCA_PDE_PS0; in entity_parse_pde()
430 (*widget)->off_val = SDCA_PDE_PS3; in entity_parse_pde()
431 (*widget)->event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD; in entity_parse_pde()
432 (*widget)->event = entity_pde_event; in entity_parse_pde()
433 (*widget)->priv = entity; in entity_parse_pde()
436 for (i = 0; i < entity->pde.num_managed; i++) in entity_parse_pde()
437 add_route(route, entity->pde.managed[i]->label, NULL, entity->label); in entity_parse_pde()
439 for (i = 0; i < entity->num_sources; i++) in entity_parse_pde()
440 add_route(route, entity->label, NULL, entity->sources[i]->label); in entity_parse_pde()
445 /* Device selector units are controlled through a group entity */
456 if (!entity->group) { in entity_parse_su_device()
457 dev_err(dev, "%s: device selector unit missing group\n", entity->label); in entity_parse_su_device()
458 return -EINVAL; in entity_parse_su_device()
461 range = sdca_selector_find_range(dev, entity->group, SDCA_CTL_GE_SELECTED_MODE, in entity_parse_su_device()
464 return -EINVAL; in entity_parse_su_device()
466 (*widget)->id = snd_soc_dapm_mux; in entity_parse_su_device()
467 (*widget)->kcontrol_news = entity->group->ge.kctl; in entity_parse_su_device()
468 (*widget)->num_kcontrols = 1; in entity_parse_su_device()
471 for (i = 0; i < entity->group->ge.num_modes; i++) { in entity_parse_su_device()
472 struct sdca_ge_mode *mode = &entity->group->ge.modes[i]; in entity_parse_su_device()
474 for (j = 0; j < mode->num_controls; j++) { in entity_parse_su_device()
475 struct sdca_ge_control *affected = &mode->controls[j]; in entity_parse_su_device()
478 if (affected->id != entity->id || in entity_parse_su_device()
479 affected->sel != SDCA_CTL_SU_SELECTOR || in entity_parse_su_device()
480 !affected->val) in entity_parse_su_device()
483 if (affected->val - 1 >= entity->num_sources) { in entity_parse_su_device()
485 entity->label, affected->val); in entity_parse_su_device()
486 return -EINVAL; in entity_parse_su_device()
489 if (++num_routes > entity->num_sources) { in entity_parse_su_device()
490 dev_err(dev, "%s: too many input routes\n", entity->label); in entity_parse_su_device()
491 return -EINVAL; in entity_parse_su_device()
495 mode->val, SDCA_SELECTED_MODE_TERM_TYPE); in entity_parse_su_device()
498 entity->label, mode->val); in entity_parse_su_device()
499 return -EINVAL; in entity_parse_su_device()
502 add_route(route, entity->label, get_terminal_name(term), in entity_parse_su_device()
503 entity->sources[affected->val - 1]->label); in entity_parse_su_device()
525 return -ENOMEM; in entity_parse_su_class()
529 return -ENOMEM; in entity_parse_su_class()
531 texts = devm_kcalloc(dev, entity->num_sources + 1, sizeof(*texts), GFP_KERNEL); in entity_parse_su_class()
533 return -ENOMEM; in entity_parse_su_class()
536 for (i = 0; i < entity->num_sources; i++) in entity_parse_su_class()
537 texts[i + 1] = entity->sources[i]->label; in entity_parse_su_class()
539 soc_enum->reg = SDW_SDCA_CTL(function->desc->adr, entity->id, control->sel, 0); in entity_parse_su_class()
540 soc_enum->items = entity->num_sources + 1; in entity_parse_su_class()
541 soc_enum->mask = roundup_pow_of_two(soc_enum->items) - 1; in entity_parse_su_class()
542 soc_enum->texts = texts; in entity_parse_su_class()
544 kctl->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in entity_parse_su_class()
545 kctl->name = "Route"; in entity_parse_su_class()
546 kctl->info = snd_soc_info_enum_double; in entity_parse_su_class()
547 kctl->get = snd_soc_dapm_get_enum_double; in entity_parse_su_class()
548 kctl->put = snd_soc_dapm_put_enum_double; in entity_parse_su_class()
549 kctl->private_value = (unsigned long)soc_enum; in entity_parse_su_class()
551 (*widget)->id = snd_soc_dapm_mux; in entity_parse_su_class()
552 (*widget)->kcontrol_news = kctl; in entity_parse_su_class()
553 (*widget)->num_kcontrols = 1; in entity_parse_su_class()
556 for (i = 0; i < entity->num_sources; i++) in entity_parse_su_class()
557 add_route(route, entity->label, texts[i + 1], entity->sources[i]->label); in entity_parse_su_class()
570 if (!entity->num_sources) { in entity_parse_su()
571 dev_err(dev, "%s: selector with no inputs\n", entity->label); in entity_parse_su()
572 return -EINVAL; in entity_parse_su()
577 return -EINVAL; in entity_parse_su()
579 if (control->layers == SDCA_ACCESS_LAYER_DEVICE) in entity_parse_su()
582 if (control->layers != SDCA_ACCESS_LAYER_CLASS) in entity_parse_su()
584 entity->label, control->layers); in entity_parse_su()
599 if (!entity->num_sources) { in entity_parse_mu()
600 dev_err(dev, "%s: selector 1 or more inputs\n", entity->label); in entity_parse_mu()
601 return -EINVAL; in entity_parse_mu()
606 return -EINVAL; in entity_parse_mu()
609 if (control->layers != SDCA_ACCESS_LAYER_CLASS) in entity_parse_mu()
611 entity->label, control->layers); in entity_parse_mu()
613 kctl = devm_kcalloc(dev, entity->num_sources, sizeof(*kctl), GFP_KERNEL); in entity_parse_mu()
615 return -ENOMEM; in entity_parse_mu()
617 for (i = 0; i < entity->num_sources; i++) { in entity_parse_mu()
622 control->label, i + 1); in entity_parse_mu()
624 return -ENOMEM; in entity_parse_mu()
628 return -ENOMEM; in entity_parse_mu()
630 mc->reg = SND_SOC_NOPM; in entity_parse_mu()
631 mc->rreg = SND_SOC_NOPM; in entity_parse_mu()
632 mc->invert = 1; // Ensure default is connected in entity_parse_mu()
633 mc->min = 0; in entity_parse_mu()
634 mc->max = 1; in entity_parse_mu()
644 (*widget)->id = snd_soc_dapm_mixer; in entity_parse_mu()
645 (*widget)->kcontrol_news = kctl; in entity_parse_mu()
646 (*widget)->num_kcontrols = entity->num_sources; in entity_parse_mu()
649 for (i = 0; i < entity->num_sources; i++) in entity_parse_mu()
650 add_route(route, entity->label, kctl[i].name, entity->sources[i]->label); in entity_parse_mu()
658 struct snd_soc_component *component = widget->dapm->component; in entity_cs_event()
659 struct sdca_entity *entity = widget->priv; in entity_cs_event()
662 return -EIO; in entity_cs_event()
664 if (entity->cs.max_delay) in entity_cs_event()
665 fsleep(entity->cs.max_delay); in entity_cs_event()
678 (*widget)->id = snd_soc_dapm_supply; in entity_parse_cs()
679 (*widget)->subseq = 1; /* Ensure these run after PDEs */ in entity_parse_cs()
680 (*widget)->event_flags = SND_SOC_DAPM_POST_PMU; in entity_parse_cs()
681 (*widget)->event = entity_cs_event; in entity_parse_cs()
682 (*widget)->priv = entity; in entity_parse_cs()
685 for (i = 0; i < entity->num_sources; i++) in entity_parse_cs()
686 add_route(route, entity->label, NULL, entity->sources[i]->label); in entity_parse_cs()
692 * sdca_asoc_populate_dapm - fill in arrays of DAPM widgets and routes
712 for (i = 0; i < function->num_entities - 1; i++) { in sdca_asoc_populate_dapm()
713 struct sdca_entity *entity = &function->entities[i]; in sdca_asoc_populate_dapm()
719 switch (entity->type) { in sdca_asoc_populate_dapm()
730 for (i = 0; i < function->num_entities - 1; i++) { in sdca_asoc_populate_dapm()
731 struct sdca_entity *entity = &function->entities[i]; in sdca_asoc_populate_dapm()
733 widget->name = entity->label; in sdca_asoc_populate_dapm()
734 widget->reg = SND_SOC_NOPM; in sdca_asoc_populate_dapm()
736 switch (entity->type) { in sdca_asoc_populate_dapm()
761 entity->label); in sdca_asoc_populate_dapm()
781 if (entity->group) in sdca_asoc_populate_dapm()
782 add_route(&route, entity->label, NULL, entity->group->label); in sdca_asoc_populate_dapm()
794 struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value; in control_limit_kctl()
798 int shift; in control_limit_kctl() local
800 if (control->type != SDCA_CTL_DATATYPE_Q7P8DB) in control_limit_kctl()
808 return -EINVAL; in control_limit_kctl()
814 min = sign_extend32(min, control->nbits - 1); in control_limit_kctl()
815 max = sign_extend32(max, control->nbits - 1); in control_limit_kctl()
819 * by a simple shift. in control_limit_kctl()
823 entity->label, control->label); in control_limit_kctl()
824 return -EINVAL; in control_limit_kctl()
829 * 64 (shift of 6) gives 1/4dB. 1/4dB is the smallest unit that is also in control_limit_kctl()
832 shift = max(ffs(step) - 1, 6); in control_limit_kctl()
836 return -ENOMEM; in control_limit_kctl()
841 tlv[3] = ((1 << shift) * 100) >> 8; in control_limit_kctl()
843 mc->min = min >> shift; in control_limit_kctl()
844 mc->max = max >> shift; in control_limit_kctl()
845 mc->shift = shift; in control_limit_kctl()
846 mc->rshift = shift; in control_limit_kctl()
847 mc->sign_bit = 15 - shift; in control_limit_kctl()
849 kctl->tlv.p = tlv; in control_limit_kctl()
850 kctl->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; in control_limit_kctl()
864 int index = 0; in populate_control() local
871 if (control->type == SDCA_CTL_DATATYPE_ONEBIT) in populate_control()
874 control_name = devm_kasprintf(dev, GFP_KERNEL, "%s %s%s", entity->label, in populate_control()
875 control->label, control_suffix); in populate_control()
877 return -ENOMEM; in populate_control()
881 return -ENOMEM; in populate_control()
883 for_each_set_bit(cn, (unsigned long *)&control->cn_list, in populate_control()
884 BITS_PER_TYPE(control->cn_list)) { in populate_control()
885 switch (index++) { in populate_control()
887 mc->reg = SDW_SDCA_CTL(function->desc->adr, entity->id, in populate_control()
888 control->sel, cn); in populate_control()
889 mc->rreg = mc->reg; in populate_control()
892 mc->rreg = SDW_SDCA_CTL(function->desc->adr, entity->id, in populate_control()
893 control->sel, cn); in populate_control()
897 entity->label, control->label); in populate_control()
898 return -EINVAL; in populate_control()
902 mc->min = 0; in populate_control()
903 mc->max = clamp((0x1ull << control->nbits) - 1, 0, type_max(mc->max)); in populate_control()
905 (*kctl)->name = control_name; in populate_control()
906 (*kctl)->private_value = (unsigned long)mc; in populate_control()
907 (*kctl)->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in populate_control()
908 (*kctl)->info = snd_soc_info_volsw; in populate_control()
909 (*kctl)->get = snd_soc_get_volsw; in populate_control()
910 (*kctl)->put = snd_soc_put_volsw; in populate_control()
913 (*kctl)->access = SNDRV_CTL_ELEM_ACCESS_READ; in populate_control()
915 (*kctl)->access = SNDRV_CTL_ELEM_ACCESS_READWRITE; in populate_control()
932 control_name = devm_kasprintf(dev, GFP_KERNEL, "%s Switch", entity->label); in populate_pin_switch()
934 return -ENOMEM; in populate_pin_switch()
936 (*kctl)->name = control_name; in populate_pin_switch()
937 (*kctl)->private_value = (unsigned long)entity->label; in populate_pin_switch()
938 (*kctl)->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in populate_pin_switch()
939 (*kctl)->info = snd_soc_dapm_info_pin_switch; in populate_pin_switch()
940 (*kctl)->get = snd_soc_dapm_get_component_pin_switch; in populate_pin_switch()
941 (*kctl)->put = snd_soc_dapm_put_component_pin_switch; in populate_pin_switch()
948 * sdca_asoc_populate_controls - fill in an array of ALSA controls for a Function
967 for (i = 0; i < function->num_entities; i++) { in sdca_asoc_populate_controls()
968 struct sdca_entity *entity = &function->entities[i]; in sdca_asoc_populate_controls()
970 switch (entity->type) { in sdca_asoc_populate_controls()
973 if (!entity->iot.is_dataport) { in sdca_asoc_populate_controls()
983 for (j = 0; j < entity->num_controls; j++) { in sdca_asoc_populate_controls()
985 &entity->controls[j], &kctl); in sdca_asoc_populate_controls()
1079 switch (entity->type) { in populate_rate_format()
1088 entity->label); in populate_rate_format()
1089 return -EINVAL; in populate_rate_format()
1092 if (entity->iot.clock) { in populate_rate_format()
1093 range = sdca_selector_find_range(dev, entity->iot.clock, in populate_rate_format()
1097 return -EINVAL; in populate_rate_format()
1099 for (i = 0; i < range->rows; i++) { in populate_rate_format()
1109 return -EINVAL; in populate_rate_format()
1111 for (i = 0; i < range->rows; i++) { in populate_rate_format()
1123 stream->formats = formats; in populate_rate_format()
1124 stream->rates = rates; in populate_rate_format()
1130 * sdca_asoc_populate_dais - fill in an array of DAI drivers for a Function
1150 for (i = 0, j = 0; i < function->num_entities - 1; i++) { in sdca_asoc_populate_dais()
1151 struct sdca_entity *entity = &function->entities[i]; in sdca_asoc_populate_dais()
1155 switch (entity->type) { in sdca_asoc_populate_dais()
1169 if (!entity->iot.is_dataport) in sdca_asoc_populate_dais()
1172 stream->stream_name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", in sdca_asoc_populate_dais()
1173 entity->label, stream_suffix); in sdca_asoc_populate_dais()
1174 if (!stream->stream_name) in sdca_asoc_populate_dais()
1175 return -ENOMEM; in sdca_asoc_populate_dais()
1177 stream->channels_min = 1; in sdca_asoc_populate_dais()
1178 stream->channels_max = SDCA_MAX_CHANNEL_COUNT; in sdca_asoc_populate_dais()
1185 dais[j].name = entity->label; in sdca_asoc_populate_dais()
1195 * sdca_asoc_populate_component - fill in a component driver for a Function
1230 return -ENOMEM; in sdca_asoc_populate_component()
1234 return -ENOMEM; in sdca_asoc_populate_component()
1238 return -ENOMEM; in sdca_asoc_populate_component()
1242 return -ENOMEM; in sdca_asoc_populate_component()
1256 component_drv->dapm_widgets = widgets; in sdca_asoc_populate_component()
1257 component_drv->num_dapm_widgets = num_widgets; in sdca_asoc_populate_component()
1258 component_drv->dapm_routes = routes; in sdca_asoc_populate_component()
1259 component_drv->num_dapm_routes = num_routes; in sdca_asoc_populate_component()
1260 component_drv->controls = controls; in sdca_asoc_populate_component()
1261 component_drv->num_controls = num_controls; in sdca_asoc_populate_component()
1271 * sdca_asoc_set_constraints - constrain channels available on a DAI
1291 struct sdca_entity *entity = &function->entities[dai->id]; in sdca_asoc_set_constraints()
1301 if (entity->type != SDCA_ENTITY_TYPE_IT) in sdca_asoc_set_constraints()
1306 return -EINVAL; in sdca_asoc_set_constraints()
1310 return -EINVAL; in sdca_asoc_set_constraints()
1312 for (i = 0; i < range->rows; i++) { in sdca_asoc_set_constraints()
1318 return -ENODEV; in sdca_asoc_set_constraints()
1320 channel_mask |= (1 << (cluster->num_channels - 1)); in sdca_asoc_set_constraints()
1324 entity->label, channel_mask); in sdca_asoc_set_constraints()
1328 return -ENOMEM; in sdca_asoc_set_constraints()
1330 constraint->count = ARRAY_SIZE(channel_list); in sdca_asoc_set_constraints()
1331 constraint->list = channel_list; in sdca_asoc_set_constraints()
1332 constraint->mask = channel_mask; in sdca_asoc_set_constraints()
1334 ret = snd_pcm_hw_constraint_list(substream->runtime, 0, in sdca_asoc_set_constraints()
1338 dev_err(dev, "%s: failed to add constraint: %d\n", entity->label, ret); in sdca_asoc_set_constraints()
1343 dai->priv = constraint; in sdca_asoc_set_constraints()
1350 * sdca_asoc_free_constraints - free constraint allocations
1359 struct snd_pcm_hw_constraint_list *constraint = dai->priv; in sdca_asoc_free_constraints()
1366 * sdca_asoc_get_port - return SoundWire port for a DAI
1381 struct sdca_entity *entity = &function->entities[dai->id]; in sdca_asoc_get_port()
1384 int sel = -EINVAL; in sdca_asoc_get_port()
1387 switch (entity->type) { in sdca_asoc_get_port()
1398 if (sel < 0 || !entity->iot.is_dataport) { in sdca_asoc_get_port()
1400 entity->label); in sdca_asoc_get_port()
1401 return -EINVAL; in sdca_asoc_get_port()
1407 return -EINVAL; in sdca_asoc_get_port()
1409 reg = SDW_SDCA_CTL(function->desc->adr, entity->id, sel, 0); in sdca_asoc_get_port()
1414 entity->label, ret); in sdca_asoc_get_port()
1418 for (i = 0; i < range->rows; i++) { in sdca_asoc_get_port()
1434 dev_err(dev, "%s: no dataport found\n", entity->label); in sdca_asoc_get_port()
1435 return -ENODEV; in sdca_asoc_get_port()
1449 return -EINVAL; in set_cluster()
1451 for (i = 0; i < range->rows; i++) { in set_cluster()
1457 return -ENODEV; in set_cluster()
1459 if (cluster->num_channels == channels) { in set_cluster()
1460 int index = sdca_range(range, SDCA_CLUSTER_BYTEINDEX, i); in set_cluster() local
1461 unsigned int reg = SDW_SDCA_CTL(function->desc->adr, in set_cluster()
1462 entity->id, sel, 0); in set_cluster()
1464 ret = regmap_update_bits(regmap, reg, 0xFF, index); in set_cluster()
1466 dev_err(dev, "%s: failed to write cluster index: %d\n", in set_cluster()
1467 entity->label, ret); in set_cluster()
1472 entity->label, index, channels); in set_cluster()
1478 dev_err(dev, "%s: no cluster for %d channels\n", entity->label, channels); in set_cluster()
1479 return -EINVAL; in set_cluster()
1492 return -EINVAL; in set_clock()
1494 for (i = 0; i < range->rows; i++) { in set_clock()
1498 unsigned int index = sdca_range(range, in set_clock() local
1501 unsigned int reg = SDW_SDCA_CTL(function->desc->adr, in set_clock()
1502 entity->id, sel, 0); in set_clock()
1504 ret = regmap_update_bits(regmap, reg, 0xFF, index); in set_clock()
1507 entity->label, ret); in set_clock()
1512 entity->label, index, rate); in set_clock()
1518 dev_err(dev, "%s: no clock rate for %dHz\n", entity->label, target_rate); in set_clock()
1519 return -EINVAL; in set_clock()
1532 return -EINVAL; in set_usage()
1534 for (i = 0; i < range->rows; i++) { in set_usage()
1540 unsigned int reg = SDW_SDCA_CTL(function->desc->adr, in set_usage()
1541 entity->id, sel, 0); in set_usage()
1546 entity->label, ret); in set_usage()
1551 entity->label, usage, target_rate, target_width); in set_usage()
1558 entity->label, target_rate, target_width); in set_usage()
1559 return -EINVAL; in set_usage()
1563 * sdca_asoc_hw_params - set SDCA channels, sample rate and bit depth
1581 struct sdca_entity *entity = &function->entities[dai->id]; in sdca_asoc_hw_params()
1588 switch (entity->type) { in sdca_asoc_hw_params()
1600 dev_err(dev, "%s: hw_params on non-terminal entity\n", entity->label); in sdca_asoc_hw_params()
1601 return -EINVAL; in sdca_asoc_hw_params()
1604 if (entity->iot.clock) { in sdca_asoc_hw_params()
1605 ret = set_clock(dev, regmap, function, entity->iot.clock, rate); in sdca_asoc_hw_params()