Lines Matching refs:tplg
80 static int soc_tplg_check_elem_count(struct soc_tplg *tplg, size_t elem_size, in soc_tplg_check_elem_count() argument
83 const u8 *end = tplg->pos + elem_size * count; in soc_tplg_check_elem_count()
85 if (end > tplg->fw->data + tplg->fw->size) { in soc_tplg_check_elem_count()
86 dev_err(tplg->dev, "ASoC: %s overflow end of data\n", in soc_tplg_check_elem_count()
94 dev_err(tplg->dev, in soc_tplg_check_elem_count()
103 static inline bool soc_tplg_is_eof(struct soc_tplg *tplg) in soc_tplg_is_eof() argument
105 const u8 *end = tplg->hdr_pos; in soc_tplg_is_eof()
107 if (end >= tplg->fw->data + tplg->fw->size) in soc_tplg_is_eof()
112 static inline unsigned long soc_tplg_get_hdr_offset(struct soc_tplg *tplg) in soc_tplg_get_hdr_offset() argument
114 return (unsigned long)(tplg->hdr_pos - tplg->fw->data); in soc_tplg_get_hdr_offset()
117 static inline unsigned long soc_tplg_get_offset(struct soc_tplg *tplg) in soc_tplg_get_offset() argument
119 return (unsigned long)(tplg->pos - tplg->fw->data); in soc_tplg_get_offset()
185 static int tplg_chan_get_reg(struct soc_tplg *tplg, in tplg_chan_get_reg() argument
198 static int tplg_chan_get_shift(struct soc_tplg *tplg, in tplg_chan_get_shift() argument
223 static inline void soc_bind_err(struct soc_tplg *tplg, in soc_bind_err() argument
226 dev_err(tplg->dev, in soc_bind_err()
229 soc_tplg_get_offset(tplg)); in soc_bind_err()
232 static inline void soc_control_err(struct soc_tplg *tplg, in soc_control_err() argument
235 dev_err(tplg->dev, in soc_control_err()
238 soc_tplg_get_offset(tplg)); in soc_control_err()
242 static int soc_tplg_vendor_load(struct soc_tplg *tplg, in soc_tplg_vendor_load() argument
247 if (tplg->ops && tplg->ops->vendor_load) in soc_tplg_vendor_load()
248 ret = tplg->ops->vendor_load(tplg->comp, tplg->index, hdr); in soc_tplg_vendor_load()
250 dev_err(tplg->dev, "ASoC: no vendor load callback for ID %d\n", in soc_tplg_vendor_load()
256 dev_err(tplg->dev, in soc_tplg_vendor_load()
258 soc_tplg_get_hdr_offset(tplg), in soc_tplg_vendor_load()
259 soc_tplg_get_hdr_offset(tplg), in soc_tplg_vendor_load()
266 static int soc_tplg_widget_load(struct soc_tplg *tplg, in soc_tplg_widget_load() argument
269 if (tplg->ops && tplg->ops->widget_load) in soc_tplg_widget_load()
270 return tplg->ops->widget_load(tplg->comp, tplg->index, w, in soc_tplg_widget_load()
278 static int soc_tplg_widget_ready(struct soc_tplg *tplg, in soc_tplg_widget_ready() argument
281 if (tplg->ops && tplg->ops->widget_ready) in soc_tplg_widget_ready()
282 return tplg->ops->widget_ready(tplg->comp, tplg->index, w, in soc_tplg_widget_ready()
289 static int soc_tplg_dai_load(struct soc_tplg *tplg, in soc_tplg_dai_load() argument
293 if (tplg->ops && tplg->ops->dai_load) in soc_tplg_dai_load()
294 return tplg->ops->dai_load(tplg->comp, tplg->index, dai_drv, in soc_tplg_dai_load()
301 static int soc_tplg_dai_link_load(struct soc_tplg *tplg, in soc_tplg_dai_link_load() argument
304 if (tplg->ops && tplg->ops->link_load) in soc_tplg_dai_link_load()
305 return tplg->ops->link_load(tplg->comp, tplg->index, link, cfg); in soc_tplg_dai_link_load()
311 static int soc_tplg_complete(struct soc_tplg *tplg) in soc_tplg_complete() argument
313 if (tplg->ops && tplg->ops->complete) in soc_tplg_complete()
314 return tplg->ops->complete(tplg->comp); in soc_tplg_complete()
344 static int soc_tplg_add_kcontrol(struct soc_tplg *tplg, in soc_tplg_add_kcontrol() argument
347 struct snd_soc_component *comp = tplg->comp; in soc_tplg_add_kcontrol()
350 tplg->dev, k, comp->name_prefix, comp, kcontrol); in soc_tplg_add_kcontrol()
471 const struct soc_tplg *tplg) in soc_tplg_kcontrol_bind_io() argument
505 ext_ops = tplg->bytes_ext_ops; in soc_tplg_kcontrol_bind_io()
506 num_ops = tplg->bytes_ext_ops_count; in soc_tplg_kcontrol_bind_io()
524 ops = tplg->io_ops; in soc_tplg_kcontrol_bind_io()
525 num_ops = tplg->io_ops_count; in soc_tplg_kcontrol_bind_io()
585 static int soc_tplg_control_load(struct soc_tplg *tplg, in soc_tplg_control_load() argument
590 if (tplg->ops && tplg->ops->control_load) in soc_tplg_control_load()
591 ret = tplg->ops->control_load(tplg->comp, tplg->index, k, hdr); in soc_tplg_control_load()
594 dev_err(tplg->dev, "ASoC: failed to init %s\n", hdr->name); in soc_tplg_control_load()
600 static int soc_tplg_create_tlv_db_scale(struct soc_tplg *tplg, in soc_tplg_create_tlv_db_scale() argument
606 p = devm_kzalloc(tplg->dev, item_len + 2 * sizeof(unsigned int), GFP_KERNEL); in soc_tplg_create_tlv_db_scale()
620 static int soc_tplg_create_tlv(struct soc_tplg *tplg, in soc_tplg_create_tlv() argument
633 return soc_tplg_create_tlv_db_scale(tplg, kc, in soc_tplg_create_tlv()
638 dev_dbg(tplg->dev, "Unsupported TLV type %d\n", in soc_tplg_create_tlv()
647 static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) in soc_tplg_dbytes_create() argument
654 if (soc_tplg_check_elem_count(tplg, in soc_tplg_dbytes_create()
659 be = (struct snd_soc_tplg_bytes_control *)tplg->pos; in soc_tplg_dbytes_create()
666 sbe = devm_kzalloc(tplg->dev, sizeof(*sbe), GFP_KERNEL); in soc_tplg_dbytes_create()
670 tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + in soc_tplg_dbytes_create()
673 dev_dbg(tplg->dev, in soc_tplg_dbytes_create()
685 if (tplg->ops) in soc_tplg_dbytes_create()
686 sbe->dobj.unload = tplg->ops->control_unload; in soc_tplg_dbytes_create()
690 ret = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, tplg); in soc_tplg_dbytes_create()
692 soc_control_err(tplg, &be->hdr, be->hdr.name); in soc_tplg_dbytes_create()
697 ret = soc_tplg_control_load(tplg, &kc, &be->hdr); in soc_tplg_dbytes_create()
702 ret = soc_tplg_add_kcontrol(tplg, &kc, &sbe->dobj.control.kcontrol); in soc_tplg_dbytes_create()
706 list_add(&sbe->dobj.list, &tplg->comp->dobj_list); in soc_tplg_dbytes_create()
712 static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) in soc_tplg_dmixer_create() argument
719 if (soc_tplg_check_elem_count(tplg, in soc_tplg_dmixer_create()
724 mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; in soc_tplg_dmixer_create()
731 sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); in soc_tplg_dmixer_create()
734 tplg->pos += (sizeof(struct snd_soc_tplg_mixer_control) + in soc_tplg_dmixer_create()
737 dev_dbg(tplg->dev, in soc_tplg_dmixer_create()
748 sm->reg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FL); in soc_tplg_dmixer_create()
749 sm->rreg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FR); in soc_tplg_dmixer_create()
750 sm->shift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FL); in soc_tplg_dmixer_create()
751 sm->rshift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR); in soc_tplg_dmixer_create()
757 sm->dobj.index = tplg->index; in soc_tplg_dmixer_create()
759 if (tplg->ops) in soc_tplg_dmixer_create()
760 sm->dobj.unload = tplg->ops->control_unload; in soc_tplg_dmixer_create()
764 ret = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, tplg); in soc_tplg_dmixer_create()
766 soc_control_err(tplg, &mc->hdr, mc->hdr.name); in soc_tplg_dmixer_create()
771 ret = soc_tplg_create_tlv(tplg, &kc, &mc->hdr); in soc_tplg_dmixer_create()
773 dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", mc->hdr.name); in soc_tplg_dmixer_create()
778 ret = soc_tplg_control_load(tplg, &kc, &mc->hdr); in soc_tplg_dmixer_create()
783 ret = soc_tplg_add_kcontrol(tplg, &kc, &sm->dobj.control.kcontrol); in soc_tplg_dmixer_create()
787 list_add(&sm->dobj.list, &tplg->comp->dobj_list); in soc_tplg_dmixer_create()
793 static int soc_tplg_denum_create_texts(struct soc_tplg *tplg, struct soc_enum *se, in soc_tplg_denum_create_texts() argument
802 devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), sizeof(char *), GFP_KERNEL); in soc_tplg_denum_create_texts()
814 se->dobj.control.dtexts[i] = devm_kstrdup(tplg->dev, ec->texts[i], GFP_KERNEL); in soc_tplg_denum_create_texts()
829 static int soc_tplg_denum_create_values(struct soc_tplg *tplg, struct soc_enum *se, in soc_tplg_denum_create_values() argument
843 se->dobj.control.dvalues = devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), in soc_tplg_denum_create_values()
859 static int soc_tplg_denum_create(struct soc_tplg *tplg, size_t size) in soc_tplg_denum_create() argument
866 if (soc_tplg_check_elem_count(tplg, in soc_tplg_denum_create()
871 ec = (struct snd_soc_tplg_enum_control *)tplg->pos; in soc_tplg_denum_create()
878 se = devm_kzalloc(tplg->dev, (sizeof(*se)), GFP_KERNEL); in soc_tplg_denum_create()
882 tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + in soc_tplg_denum_create()
885 dev_dbg(tplg->dev, "ASoC: adding enum kcontrol %s size %d\n", in soc_tplg_denum_create()
894 se->reg = tplg_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); in soc_tplg_denum_create()
895 se->shift_l = tplg_chan_get_shift(tplg, ec->channel, in soc_tplg_denum_create()
897 se->shift_r = tplg_chan_get_shift(tplg, ec->channel, in soc_tplg_denum_create()
901 se->dobj.index = tplg->index; in soc_tplg_denum_create()
903 if (tplg->ops) in soc_tplg_denum_create()
904 se->dobj.unload = tplg->ops->control_unload; in soc_tplg_denum_create()
910 ret = soc_tplg_denum_create_values(tplg, se, ec); in soc_tplg_denum_create()
912 dev_err(tplg->dev, in soc_tplg_denum_create()
921 ret = soc_tplg_denum_create_texts(tplg, se, ec); in soc_tplg_denum_create()
923 dev_err(tplg->dev, in soc_tplg_denum_create()
931 dev_err(tplg->dev, in soc_tplg_denum_create()
938 ret = soc_tplg_kcontrol_bind_io(&ec->hdr, &kc, tplg); in soc_tplg_denum_create()
940 soc_control_err(tplg, &ec->hdr, ec->hdr.name); in soc_tplg_denum_create()
945 ret = soc_tplg_control_load(tplg, &kc, &ec->hdr); in soc_tplg_denum_create()
950 ret = soc_tplg_add_kcontrol(tplg, &kc, &se->dobj.control.kcontrol); in soc_tplg_denum_create()
954 list_add(&se->dobj.list, &tplg->comp->dobj_list); in soc_tplg_denum_create()
960 static int soc_tplg_kcontrol_elems_load(struct soc_tplg *tplg, in soc_tplg_kcontrol_elems_load() argument
966 dev_dbg(tplg->dev, "ASoC: adding %d kcontrols at 0x%lx\n", hdr->count, in soc_tplg_kcontrol_elems_load()
967 soc_tplg_get_offset(tplg)); in soc_tplg_kcontrol_elems_load()
970 struct snd_soc_tplg_ctl_hdr *control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos; in soc_tplg_kcontrol_elems_load()
973 dev_err(tplg->dev, "ASoC: invalid control size\n"); in soc_tplg_kcontrol_elems_load()
985 ret = soc_tplg_dmixer_create(tplg, le32_to_cpu(hdr->payload_size)); in soc_tplg_kcontrol_elems_load()
992 ret = soc_tplg_denum_create(tplg, le32_to_cpu(hdr->payload_size)); in soc_tplg_kcontrol_elems_load()
995 ret = soc_tplg_dbytes_create(tplg, le32_to_cpu(hdr->payload_size)); in soc_tplg_kcontrol_elems_load()
998 soc_bind_err(tplg, control_hdr, i); in soc_tplg_kcontrol_elems_load()
1002 dev_err(tplg->dev, "ASoC: invalid control\n"); in soc_tplg_kcontrol_elems_load()
1012 static int soc_tplg_add_route(struct soc_tplg *tplg, in soc_tplg_add_route() argument
1015 if (tplg->ops && tplg->ops->dapm_route_load) in soc_tplg_add_route()
1016 return tplg->ops->dapm_route_load(tplg->comp, tplg->index, in soc_tplg_add_route()
1022 static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, in soc_tplg_dapm_graph_elems_load() argument
1025 struct snd_soc_dapm_context *dapm = &tplg->comp->dapm; in soc_tplg_dapm_graph_elems_load()
1034 if (soc_tplg_check_elem_count(tplg, in soc_tplg_dapm_graph_elems_load()
1039 dev_dbg(tplg->dev, "ASoC: adding %d DAPM routes for index %d\n", count, in soc_tplg_dapm_graph_elems_load()
1043 route = devm_kzalloc(tplg->dev, sizeof(*route), GFP_KERNEL); in soc_tplg_dapm_graph_elems_load()
1046 elem = (struct snd_soc_tplg_dapm_graph_elem *)tplg->pos; in soc_tplg_dapm_graph_elems_load()
1047 tplg->pos += sizeof(struct snd_soc_tplg_dapm_graph_elem); in soc_tplg_dapm_graph_elems_load()
1057 route->source = devm_kstrdup(tplg->dev, elem->source, GFP_KERNEL); in soc_tplg_dapm_graph_elems_load()
1058 route->sink = devm_kstrdup(tplg->dev, elem->sink, GFP_KERNEL); in soc_tplg_dapm_graph_elems_load()
1065 route->control = devm_kstrdup(tplg->dev, elem->control, GFP_KERNEL); in soc_tplg_dapm_graph_elems_load()
1074 if (tplg->ops) in soc_tplg_dapm_graph_elems_load()
1075 route->dobj.unload = tplg->ops->dapm_route_unload; in soc_tplg_dapm_graph_elems_load()
1076 route->dobj.index = tplg->index; in soc_tplg_dapm_graph_elems_load()
1077 list_add(&route->dobj.list, &tplg->comp->dobj_list); in soc_tplg_dapm_graph_elems_load()
1079 ret = soc_tplg_add_route(tplg, route); in soc_tplg_dapm_graph_elems_load()
1081 dev_err(tplg->dev, "ASoC: topology: add_route failed: %d\n", ret); in soc_tplg_dapm_graph_elems_load()
1092 static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) in soc_tplg_dapm_widget_dmixer_create() argument
1098 mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; in soc_tplg_dapm_widget_dmixer_create()
1105 sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); in soc_tplg_dapm_widget_dmixer_create()
1109 tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + in soc_tplg_dapm_widget_dmixer_create()
1112 dev_dbg(tplg->dev, " adding DAPM widget mixer control %s\n", in soc_tplg_dapm_widget_dmixer_create()
1116 kc->name = devm_kstrdup(tplg->dev, mc->hdr.name, GFP_KERNEL); in soc_tplg_dapm_widget_dmixer_create()
1123 sm->reg = tplg_chan_get_reg(tplg, mc->channel, in soc_tplg_dapm_widget_dmixer_create()
1125 sm->rreg = tplg_chan_get_reg(tplg, mc->channel, in soc_tplg_dapm_widget_dmixer_create()
1127 sm->shift = tplg_chan_get_shift(tplg, mc->channel, in soc_tplg_dapm_widget_dmixer_create()
1129 sm->rshift = tplg_chan_get_shift(tplg, mc->channel, in soc_tplg_dapm_widget_dmixer_create()
1136 sm->dobj.index = tplg->index; in soc_tplg_dapm_widget_dmixer_create()
1140 err = soc_tplg_kcontrol_bind_io(&mc->hdr, kc, tplg); in soc_tplg_dapm_widget_dmixer_create()
1142 soc_control_err(tplg, &mc->hdr, mc->hdr.name); in soc_tplg_dapm_widget_dmixer_create()
1147 err = soc_tplg_create_tlv(tplg, kc, &mc->hdr); in soc_tplg_dapm_widget_dmixer_create()
1149 dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", in soc_tplg_dapm_widget_dmixer_create()
1155 err = soc_tplg_control_load(tplg, kc, &mc->hdr); in soc_tplg_dapm_widget_dmixer_create()
1162 static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) in soc_tplg_dapm_widget_denum_create() argument
1168 ec = (struct snd_soc_tplg_enum_control *)tplg->pos; in soc_tplg_dapm_widget_denum_create()
1174 se = devm_kzalloc(tplg->dev, sizeof(*se), GFP_KERNEL); in soc_tplg_dapm_widget_denum_create()
1178 tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + in soc_tplg_dapm_widget_denum_create()
1181 dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n", in soc_tplg_dapm_widget_denum_create()
1185 kc->name = devm_kstrdup(tplg->dev, ec->hdr.name, GFP_KERNEL); in soc_tplg_dapm_widget_denum_create()
1192 se->reg = tplg_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); in soc_tplg_dapm_widget_denum_create()
1193 se->shift_l = tplg_chan_get_shift(tplg, ec->channel, in soc_tplg_dapm_widget_denum_create()
1195 se->shift_r = tplg_chan_get_shift(tplg, ec->channel, in soc_tplg_dapm_widget_denum_create()
1200 se->dobj.index = tplg->index; in soc_tplg_dapm_widget_denum_create()
1205 err = soc_tplg_denum_create_values(tplg, se, ec); in soc_tplg_dapm_widget_denum_create()
1207 dev_err(tplg->dev, "ASoC: could not create values for %s\n", in soc_tplg_dapm_widget_denum_create()
1215 err = soc_tplg_denum_create_texts(tplg, se, ec); in soc_tplg_dapm_widget_denum_create()
1217 dev_err(tplg->dev, "ASoC: could not create texts for %s\n", in soc_tplg_dapm_widget_denum_create()
1223 dev_err(tplg->dev, "ASoC: invalid enum control type %d for %s\n", in soc_tplg_dapm_widget_denum_create()
1229 err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, tplg); in soc_tplg_dapm_widget_denum_create()
1231 soc_control_err(tplg, &ec->hdr, ec->hdr.name); in soc_tplg_dapm_widget_denum_create()
1236 err = soc_tplg_control_load(tplg, kc, &ec->hdr); in soc_tplg_dapm_widget_denum_create()
1243 static int soc_tplg_dapm_widget_dbytes_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) in soc_tplg_dapm_widget_dbytes_create() argument
1249 be = (struct snd_soc_tplg_bytes_control *)tplg->pos; in soc_tplg_dapm_widget_dbytes_create()
1256 sbe = devm_kzalloc(tplg->dev, sizeof(*sbe), GFP_KERNEL); in soc_tplg_dapm_widget_dbytes_create()
1260 tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + in soc_tplg_dapm_widget_dbytes_create()
1263 dev_dbg(tplg->dev, in soc_tplg_dapm_widget_dbytes_create()
1268 kc->name = devm_kstrdup(tplg->dev, be->hdr.name, GFP_KERNEL); in soc_tplg_dapm_widget_dbytes_create()
1278 err = soc_tplg_kcontrol_bind_io(&be->hdr, kc, tplg); in soc_tplg_dapm_widget_dbytes_create()
1280 soc_control_err(tplg, &be->hdr, be->hdr.name); in soc_tplg_dapm_widget_dbytes_create()
1285 err = soc_tplg_control_load(tplg, kc, &be->hdr); in soc_tplg_dapm_widget_dbytes_create()
1292 static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, in soc_tplg_dapm_widget_create() argument
1295 struct snd_soc_dapm_context *dapm = &tplg->comp->dapm; in soc_tplg_dapm_widget_create()
1298 struct snd_soc_card *card = tplg->comp->card; in soc_tplg_dapm_widget_create()
1314 dev_dbg(tplg->dev, "ASoC: creating DAPM widget %s id %d\n", in soc_tplg_dapm_widget_create()
1341 template.dobj.index = tplg->index; in soc_tplg_dapm_widget_create()
1343 tplg->pos += in soc_tplg_dapm_widget_create()
1353 kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL); in soc_tplg_dapm_widget_create()
1359 kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int), in soc_tplg_dapm_widget_create()
1367 control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos; in soc_tplg_dapm_widget_create()
1379 ret = soc_tplg_dapm_widget_dmixer_create(tplg, &kc[i]); in soc_tplg_dapm_widget_create()
1392 ret = soc_tplg_dapm_widget_denum_create(tplg, &kc[i]); in soc_tplg_dapm_widget_create()
1401 ret = soc_tplg_dapm_widget_dbytes_create(tplg, &kc[i]); in soc_tplg_dapm_widget_create()
1406 dev_err(tplg->dev, "ASoC: invalid widget control type %d:%d:%d\n", in soc_tplg_dapm_widget_create()
1415 dev_dbg(tplg->dev, "ASoC: template %s with %d/%d/%d (mixer/enum/bytes) control\n", in soc_tplg_dapm_widget_create()
1419 ret = soc_tplg_widget_load(tplg, &template, w); in soc_tplg_dapm_widget_create()
1436 if (tplg->ops) in soc_tplg_dapm_widget_create()
1437 widget->dobj.unload = tplg->ops->widget_unload; in soc_tplg_dapm_widget_create()
1438 widget->dobj.index = tplg->index; in soc_tplg_dapm_widget_create()
1439 list_add(&widget->dobj.list, &tplg->comp->dobj_list); in soc_tplg_dapm_widget_create()
1441 ret = soc_tplg_widget_ready(tplg, widget, w); in soc_tplg_dapm_widget_create()
1460 static int soc_tplg_dapm_widget_elems_load(struct soc_tplg *tplg, in soc_tplg_dapm_widget_elems_load() argument
1467 dev_dbg(tplg->dev, "ASoC: adding %d DAPM widgets\n", count); in soc_tplg_dapm_widget_elems_load()
1470 struct snd_soc_tplg_dapm_widget *widget = (struct snd_soc_tplg_dapm_widget *) tplg->pos; in soc_tplg_dapm_widget_elems_load()
1478 if (soc_tplg_get_offset(tplg) + sizeof(*widget) >= tplg->fw->size) { in soc_tplg_dapm_widget_elems_load()
1479 dev_err(tplg->dev, "ASoC: invalid widget data size\n"); in soc_tplg_dapm_widget_elems_load()
1485 dev_err(tplg->dev, "ASoC: invalid widget size\n"); in soc_tplg_dapm_widget_elems_load()
1490 if (soc_tplg_get_offset(tplg) + le32_to_cpu(widget->priv.size) >= tplg->fw->size) { in soc_tplg_dapm_widget_elems_load()
1491 dev_err(tplg->dev, "ASoC: invalid widget private data size\n"); in soc_tplg_dapm_widget_elems_load()
1495 ret = soc_tplg_dapm_widget_create(tplg, widget); in soc_tplg_dapm_widget_elems_load()
1497 dev_err(tplg->dev, "ASoC: failed to load widget %s\n", in soc_tplg_dapm_widget_elems_load()
1506 static int soc_tplg_dapm_complete(struct soc_tplg *tplg) in soc_tplg_dapm_complete() argument
1508 struct snd_soc_card *card = tplg->comp->card; in soc_tplg_dapm_complete()
1515 dev_warn(tplg->dev, "ASoC: Parent card not yet available, widget card binding deferred\n"); in soc_tplg_dapm_complete()
1521 dev_err(tplg->dev, "ASoC: failed to create new widgets %d\n", ret); in soc_tplg_dapm_complete()
1526 static int set_stream_info(struct soc_tplg *tplg, struct snd_soc_pcm_stream *stream, in set_stream_info() argument
1529 stream->stream_name = devm_kstrdup(tplg->dev, caps->name, GFP_KERNEL); in set_stream_info()
1566 static int soc_tplg_dai_create(struct soc_tplg *tplg, in soc_tplg_dai_create() argument
1574 snd_soc_component_get_dapm(tplg->comp); in soc_tplg_dai_create()
1577 dai_drv = devm_kzalloc(tplg->dev, sizeof(struct snd_soc_dai_driver), GFP_KERNEL); in soc_tplg_dai_create()
1582 dai_drv->name = devm_kstrdup(tplg->dev, pcm->dai_name, GFP_KERNEL); in soc_tplg_dai_create()
1593 ret = set_stream_info(tplg, stream, caps); in soc_tplg_dai_create()
1601 ret = set_stream_info(tplg, stream, caps); in soc_tplg_dai_create()
1610 ret = soc_tplg_dai_load(tplg, dai_drv, pcm, NULL); in soc_tplg_dai_create()
1612 dev_err(tplg->dev, "ASoC: DAI loading failed\n"); in soc_tplg_dai_create()
1616 dai_drv->dobj.index = tplg->index; in soc_tplg_dai_create()
1618 if (tplg->ops) in soc_tplg_dai_create()
1619 dai_drv->dobj.unload = tplg->ops->dai_unload; in soc_tplg_dai_create()
1620 list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list); in soc_tplg_dai_create()
1623 dai = snd_soc_register_dai(tplg->comp, dai_drv, false); in soc_tplg_dai_create()
1665 static int soc_tplg_fe_link_create(struct soc_tplg *tplg, in soc_tplg_fe_link_create() argument
1673 link = devm_kzalloc(tplg->dev, sizeof(*link) + (3 * sizeof(*dlc)), GFP_KERNEL); in soc_tplg_fe_link_create()
1682 link->dobj.index = tplg->index; in soc_tplg_fe_link_create()
1684 if (tplg->ops) in soc_tplg_fe_link_create()
1685 link->dobj.unload = tplg->ops->link_unload; in soc_tplg_fe_link_create()
1688 link->name = devm_kstrdup(tplg->dev, pcm->pcm_name, GFP_KERNEL); in soc_tplg_fe_link_create()
1689 link->stream_name = devm_kstrdup(tplg->dev, pcm->pcm_name, GFP_KERNEL); in soc_tplg_fe_link_create()
1698 link->cpus->dai_name = devm_kstrdup(tplg->dev, pcm->dai_name, GFP_KERNEL); in soc_tplg_fe_link_create()
1730 ret = soc_tplg_dai_link_load(tplg, link, NULL); in soc_tplg_fe_link_create()
1732 dev_err(tplg->dev, "ASoC: FE link loading failed\n"); in soc_tplg_fe_link_create()
1736 ret = snd_soc_add_pcm_runtimes(tplg->comp->card, link, 1); in soc_tplg_fe_link_create()
1739 dev_err(tplg->dev, "ASoC: adding FE link failed\n"); in soc_tplg_fe_link_create()
1743 list_add(&link->dobj.list, &tplg->comp->dobj_list); in soc_tplg_fe_link_create()
1751 static int soc_tplg_pcm_create(struct soc_tplg *tplg, in soc_tplg_pcm_create() argument
1756 ret = soc_tplg_dai_create(tplg, pcm); in soc_tplg_pcm_create()
1760 return soc_tplg_fe_link_create(tplg, pcm); in soc_tplg_pcm_create()
1791 static int pcm_new_ver(struct soc_tplg *tplg, in pcm_new_ver() argument
1802 dev_err(tplg->dev, "ASoC: invalid PCM size\n"); in pcm_new_ver()
1806 dev_warn(tplg->dev, "ASoC: old version of PCM\n"); in pcm_new_ver()
1832 static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg, in soc_tplg_pcm_elems_load() argument
1845 pcm = (struct snd_soc_tplg_pcm *)tplg->pos; in soc_tplg_pcm_elems_load()
1849 dev_err(tplg->dev, "ASoC: invalid size %d for PCM elems\n", in soc_tplg_pcm_elems_load()
1854 if (soc_tplg_check_elem_count(tplg, in soc_tplg_pcm_elems_load()
1861 pcm = (struct snd_soc_tplg_pcm *)tplg->pos; in soc_tplg_pcm_elems_load()
1872 ret = pcm_new_ver(tplg, pcm, &_pcm); in soc_tplg_pcm_elems_load()
1878 ret = soc_tplg_pcm_create(tplg, _pcm); in soc_tplg_pcm_elems_load()
1888 tplg->pos += size + le32_to_cpu(_pcm->priv.size); in soc_tplg_pcm_elems_load()
1894 dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count); in soc_tplg_pcm_elems_load()
1976 static int link_new_ver(struct soc_tplg *tplg, in link_new_ver() argument
1988 dev_err(tplg->dev, "ASoC: invalid physical link config size\n"); in link_new_ver()
1992 dev_warn(tplg->dev, "ASoC: old version of physical link config\n"); in link_new_ver()
2051 static int soc_tplg_link_config(struct soc_tplg *tplg, in soc_tplg_link_config() argument
2075 link = snd_soc_find_dai_link(tplg->comp->card, le32_to_cpu(cfg->id), in soc_tplg_link_config()
2078 dev_err(tplg->dev, "ASoC: physical link %s (id %d) not exist\n", in soc_tplg_link_config()
2094 ret = soc_tplg_dai_link_load(tplg, link, cfg); in soc_tplg_link_config()
2096 dev_err(tplg->dev, "ASoC: physical link loading failed\n"); in soc_tplg_link_config()
2101 link->dobj.index = tplg->index; in soc_tplg_link_config()
2103 if (tplg->ops) in soc_tplg_link_config()
2104 link->dobj.unload = tplg->ops->link_unload; in soc_tplg_link_config()
2105 list_add(&link->dobj.list, &tplg->comp->dobj_list); in soc_tplg_link_config()
2112 static int soc_tplg_link_elems_load(struct soc_tplg *tplg, in soc_tplg_link_elems_load() argument
2124 link = (struct snd_soc_tplg_link_config *)tplg->pos; in soc_tplg_link_elems_load()
2128 dev_err(tplg->dev, "ASoC: invalid size %d for physical link elems\n", in soc_tplg_link_elems_load()
2133 if (soc_tplg_check_elem_count(tplg, size, count, in soc_tplg_link_elems_load()
2140 link = (struct snd_soc_tplg_link_config *)tplg->pos; in soc_tplg_link_elems_load()
2147 ret = link_new_ver(tplg, link, &_link); in soc_tplg_link_elems_load()
2152 ret = soc_tplg_link_config(tplg, _link); in soc_tplg_link_elems_load()
2162 tplg->pos += size + le32_to_cpu(_link->priv.size); in soc_tplg_link_elems_load()
2179 static int soc_tplg_dai_config(struct soc_tplg *tplg, in soc_tplg_dai_config() argument
2194 dev_err(tplg->dev, "ASoC: physical DAI %s not registered\n", in soc_tplg_dai_config()
2200 dev_err(tplg->dev, "ASoC: physical DAI %s id mismatch\n", in soc_tplg_dai_config()
2212 ret = set_stream_info(tplg, stream, caps); in soc_tplg_dai_config()
2220 ret = set_stream_info(tplg, stream, caps); in soc_tplg_dai_config()
2231 ret = soc_tplg_dai_load(tplg, dai_drv, NULL, dai); in soc_tplg_dai_config()
2233 dev_err(tplg->dev, "ASoC: DAI loading failed\n"); in soc_tplg_dai_config()
2244 static int soc_tplg_dai_elems_load(struct soc_tplg *tplg, in soc_tplg_dai_elems_load() argument
2254 struct snd_soc_tplg_dai *dai = (struct snd_soc_tplg_dai *)tplg->pos; in soc_tplg_dai_elems_load()
2258 dev_err(tplg->dev, "ASoC: invalid physical DAI size\n"); in soc_tplg_dai_elems_load()
2262 ret = soc_tplg_dai_config(tplg, dai); in soc_tplg_dai_elems_load()
2264 dev_err(tplg->dev, "ASoC: failed to configure DAI\n"); in soc_tplg_dai_elems_load()
2268 tplg->pos += (sizeof(*dai) + le32_to_cpu(dai->priv.size)); in soc_tplg_dai_elems_load()
2271 dev_dbg(tplg->dev, "ASoC: Configure %d BE DAIs\n", count); in soc_tplg_dai_elems_load()
2284 static int manifest_new_ver(struct soc_tplg *tplg, in manifest_new_ver() argument
2296 dev_warn(tplg->dev, "ASoC: invalid manifest size %d\n", in manifest_new_ver()
2303 dev_warn(tplg->dev, "ASoC: old version of manifest\n"); in manifest_new_ver()
2326 static int soc_tplg_manifest_load(struct soc_tplg *tplg, in soc_tplg_manifest_load() argument
2333 manifest = (struct snd_soc_tplg_manifest *)tplg->pos; in soc_tplg_manifest_load()
2342 ret = manifest_new_ver(tplg, manifest, &_manifest); in soc_tplg_manifest_load()
2348 if (tplg->ops && tplg->ops->manifest) in soc_tplg_manifest_load()
2349 ret = tplg->ops->manifest(tplg->comp, tplg->index, _manifest); in soc_tplg_manifest_load()
2358 static int soc_tplg_valid_header(struct soc_tplg *tplg, in soc_tplg_valid_header() argument
2362 dev_err(tplg->dev, in soc_tplg_valid_header()
2364 le32_to_cpu(hdr->type), soc_tplg_get_hdr_offset(tplg), in soc_tplg_valid_header()
2365 tplg->fw->size); in soc_tplg_valid_header()
2369 if (soc_tplg_get_hdr_offset(tplg) + le32_to_cpu(hdr->payload_size) >= tplg->fw->size) { in soc_tplg_valid_header()
2370 dev_err(tplg->dev, in soc_tplg_valid_header()
2372 le32_to_cpu(hdr->type), soc_tplg_get_hdr_offset(tplg), in soc_tplg_valid_header()
2379 dev_err(tplg->dev, in soc_tplg_valid_header()
2381 tplg->pass, hdr->magic, in soc_tplg_valid_header()
2382 soc_tplg_get_hdr_offset(tplg), tplg->fw->size); in soc_tplg_valid_header()
2387 dev_err(tplg->dev, in soc_tplg_valid_header()
2389 tplg->pass, hdr->magic, in soc_tplg_valid_header()
2390 soc_tplg_get_hdr_offset(tplg), tplg->fw->size); in soc_tplg_valid_header()
2397 dev_err(tplg->dev, in soc_tplg_valid_header()
2399 tplg->pass, hdr->abi, in soc_tplg_valid_header()
2400 SND_SOC_TPLG_ABI_VERSION, soc_tplg_get_hdr_offset(tplg), in soc_tplg_valid_header()
2401 tplg->fw->size); in soc_tplg_valid_header()
2406 dev_err(tplg->dev, "ASoC: header has 0 size at offset 0x%lx.\n", in soc_tplg_valid_header()
2407 soc_tplg_get_hdr_offset(tplg)); in soc_tplg_valid_header()
2415 static int soc_tplg_load_header(struct soc_tplg *tplg, in soc_tplg_load_header() argument
2418 int (*elem_load)(struct soc_tplg *tplg, in soc_tplg_load_header()
2422 tplg->pos = tplg->hdr_pos + sizeof(struct snd_soc_tplg_hdr); in soc_tplg_load_header()
2424 tplg->index = le32_to_cpu(hdr->index); in soc_tplg_load_header()
2466 if (tplg->pass == hdr_pass) { in soc_tplg_load_header()
2467 dev_dbg(tplg->dev, in soc_tplg_load_header()
2470 hdr->vendor_type, tplg->pass); in soc_tplg_load_header()
2471 return elem_load(tplg, hdr); in soc_tplg_load_header()
2478 static int soc_tplg_process_headers(struct soc_tplg *tplg) in soc_tplg_process_headers() argument
2483 for (tplg->pass = SOC_TPLG_PASS_START; tplg->pass <= SOC_TPLG_PASS_END; tplg->pass++) { in soc_tplg_process_headers()
2486 tplg->hdr_pos = tplg->fw->data; in soc_tplg_process_headers()
2487 hdr = (struct snd_soc_tplg_hdr *)tplg->hdr_pos; in soc_tplg_process_headers()
2489 while (!soc_tplg_is_eof(tplg)) { in soc_tplg_process_headers()
2492 ret = soc_tplg_valid_header(tplg, hdr); in soc_tplg_process_headers()
2497 ret = soc_tplg_load_header(tplg, hdr); in soc_tplg_process_headers()
2500 dev_err(tplg->dev, in soc_tplg_process_headers()
2508 tplg->hdr_pos += le32_to_cpu(hdr->payload_size) + in soc_tplg_process_headers()
2510 hdr = (struct snd_soc_tplg_hdr *)tplg->hdr_pos; in soc_tplg_process_headers()
2516 ret = soc_tplg_dapm_complete(tplg); in soc_tplg_process_headers()
2521 static int soc_tplg_load(struct soc_tplg *tplg) in soc_tplg_load() argument
2525 ret = soc_tplg_process_headers(tplg); in soc_tplg_load()
2527 return soc_tplg_complete(tplg); in soc_tplg_load()
2536 struct soc_tplg tplg; in snd_soc_tplg_component_load() local
2550 memset(&tplg, 0, sizeof(tplg)); in snd_soc_tplg_component_load()
2551 tplg.fw = fw; in snd_soc_tplg_component_load()
2552 tplg.dev = comp->card->dev; in snd_soc_tplg_component_load()
2553 tplg.comp = comp; in snd_soc_tplg_component_load()
2555 tplg.ops = ops; in snd_soc_tplg_component_load()
2556 tplg.io_ops = ops->io_ops; in snd_soc_tplg_component_load()
2557 tplg.io_ops_count = ops->io_ops_count; in snd_soc_tplg_component_load()
2558 tplg.bytes_ext_ops = ops->bytes_ext_ops; in snd_soc_tplg_component_load()
2559 tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count; in snd_soc_tplg_component_load()
2562 ret = soc_tplg_load(&tplg); in snd_soc_tplg_component_load()