Lines Matching +full:base +full:- +full:db
2 Copyright(c) 2014-2015 Intel Corporation
32 /* place the multi-bit values on top - like read_write - for save */
69 hdr->access |= ctl_access[j].value; in parse_access_values()
116 if (hdr->access == 0) in tplg_save_access()
119 access = hdr->access; in tplg_save_access()
133 access = hdr->access; in tplg_save_access()
150 struct snd_soc_tplg_mixer_control *mixer_ctrl = elem->mixer_ctrl; in copy_tlv()
151 struct snd_soc_tplg_ctl_tlv *tlv = ref->tlv; in copy_tlv()
153 tplg_dbg("TLV '%s' used by '%s", ref->id, elem->id); in copy_tlv()
156 mixer_ctrl->hdr.tlv = *tlv; in copy_tlv()
165 struct list_head *base, *pos; in tplg_build_mixer_control() local
168 base = &elem->ref_list; in tplg_build_mixer_control()
171 list_for_each(pos, base) { in tplg_build_mixer_control()
174 if (ref->elem) in tplg_build_mixer_control()
177 if (ref->type == SND_TPLG_TYPE_TLV) { in tplg_build_mixer_control()
178 ref->elem = tplg_elem_lookup(&tplg->tlv_list, in tplg_build_mixer_control()
179 ref->id, SND_TPLG_TYPE_TLV, elem->index); in tplg_build_mixer_control()
180 if (ref->elem) in tplg_build_mixer_control()
181 err = copy_tlv(elem, ref->elem); in tplg_build_mixer_control()
183 } else if (ref->type == SND_TPLG_TYPE_DATA) { in tplg_build_mixer_control()
189 if (!ref->elem) { in tplg_build_mixer_control()
191 " control '%s'", ref->id, elem->id); in tplg_build_mixer_control()
192 return -EINVAL; in tplg_build_mixer_control()
203 struct snd_soc_tplg_enum_control *ec = enum_elem->enum_ctrl; in copy_enum_texts()
204 struct tplg_texts *texts = ref_elem->texts; in copy_enum_texts()
206 memcpy(ec->texts, texts->items, in copy_enum_texts()
208 ec->items += texts->num_items; in copy_enum_texts()
216 struct list_head *base, *pos; in tplg_build_enum_control() local
219 base = &elem->ref_list; in tplg_build_enum_control()
221 list_for_each(pos, base) { in tplg_build_enum_control()
224 if (ref->elem) in tplg_build_enum_control()
227 if (ref->type == SND_TPLG_TYPE_TEXT) { in tplg_build_enum_control()
228 ref->elem = tplg_elem_lookup(&tplg->text_list, in tplg_build_enum_control()
229 ref->id, SND_TPLG_TYPE_TEXT, elem->index); in tplg_build_enum_control()
230 if (ref->elem) in tplg_build_enum_control()
231 copy_enum_texts(elem, ref->elem); in tplg_build_enum_control()
233 } else if (ref->type == SND_TPLG_TYPE_DATA) { in tplg_build_enum_control()
238 if (!ref->elem) { in tplg_build_enum_control()
240 " control '%s'", ref->id, elem->id); in tplg_build_enum_control()
241 return -EINVAL; in tplg_build_enum_control()
252 struct list_head *base, *pos; in tplg_build_bytes_control() local
255 base = &elem->ref_list; in tplg_build_bytes_control()
257 list_for_each(pos, base) { in tplg_build_bytes_control()
260 if (ref->elem) in tplg_build_bytes_control()
263 if (ref->type == SND_TPLG_TYPE_DATA) { in tplg_build_bytes_control()
275 struct list_head *base, *pos; in tplg_build_controls() local
279 base = &tplg->mixer_list; in tplg_build_controls()
280 list_for_each(pos, base) { in tplg_build_controls()
288 tplg->manifest.control_elems++; in tplg_build_controls()
291 base = &tplg->enum_list; in tplg_build_controls()
292 list_for_each(pos, base) { in tplg_build_controls()
300 tplg->manifest.control_elems++; in tplg_build_controls()
303 base = &tplg->bytes_ext_list; in tplg_build_controls()
304 list_for_each(pos, base) { in tplg_build_controls()
312 tplg->manifest.control_elems++; in tplg_build_controls()
322 * Parse DBScale describing min, step, mute in DB.
328 struct snd_soc_tplg_ctl_tlv *tplg_tlv = elem->tlv; in tplg_parse_tlv_dbscale()
333 tplg_dbg(" scale: %s", elem->id); in tplg_parse_tlv_dbscale()
335 tplg_tlv->size = sizeof(struct snd_soc_tplg_ctl_tlv); in tplg_parse_tlv_dbscale()
336 tplg_tlv->type = SNDRV_CTL_TLVT_DB_SCALE; in tplg_parse_tlv_dbscale()
337 scale = &tplg_tlv->scale; in tplg_parse_tlv_dbscale()
345 return -EINVAL; in tplg_parse_tlv_dbscale()
355 scale->min = val; in tplg_parse_tlv_dbscale()
357 scale->step = val; in tplg_parse_tlv_dbscale()
359 scale->mute = val; in tplg_parse_tlv_dbscale()
379 return -ENOMEM; in tplg_parse_tlv()
405 struct snd_soc_tplg_ctl_tlv *tlv = elem->tlv; in tplg_save_tlv()
409 if (tlv->type != SNDRV_CTL_TLVT_DB_SCALE) { in tplg_save_tlv()
411 return -EINVAL; in tplg_save_tlv()
414 scale = &tlv->scale; in tplg_save_tlv()
415 err = tplg_save_printf(dst, NULL, "'%s' {\n", elem->id); in tplg_save_tlv()
418 if (err >= 0 && scale->min) in tplg_save_tlv()
419 err = tplg_save_printf(dst, pfx, "\t\tmin %i\n", scale->min); in tplg_save_tlv()
420 if (err >= 0 && scale->step > 0) in tplg_save_tlv()
421 err = tplg_save_printf(dst, pfx, "\t\tstep %i\n", scale->step); in tplg_save_tlv()
422 if (err >= 0 && scale->mute > 0) in tplg_save_tlv()
423 err = tplg_save_printf(dst, pfx, "\t\tmute %i\n", scale->mute); in tplg_save_tlv()
446 return -ENOMEM; in tplg_parse_control_bytes()
448 be = elem->bytes_ext; in tplg_parse_control_bytes()
449 be->size = elem->size; in tplg_parse_control_bytes()
450 snd_strlcpy(be->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); in tplg_parse_control_bytes()
451 be->hdr.type = SND_SOC_TPLG_TYPE_BYTES; in tplg_parse_control_bytes()
453 tplg_dbg(" Control Bytes: %s", elem->id); in tplg_parse_control_bytes()
466 if (strcmp(id, "base") == 0) { in tplg_parse_control_bytes()
468 return -EINVAL; in tplg_parse_control_bytes()
470 be->base = ival; in tplg_parse_control_bytes()
471 tplg_dbg("\t%s: %d", id, be->base); in tplg_parse_control_bytes()
477 return -EINVAL; in tplg_parse_control_bytes()
479 be->num_regs = ival; in tplg_parse_control_bytes()
480 tplg_dbg("\t%s: %d", id, be->num_regs); in tplg_parse_control_bytes()
486 return -EINVAL; in tplg_parse_control_bytes()
488 be->max = ival; in tplg_parse_control_bytes()
489 tplg_dbg("\t%s: %d", id, be->max); in tplg_parse_control_bytes()
495 return -EINVAL; in tplg_parse_control_bytes()
497 be->mask = ival; in tplg_parse_control_bytes()
498 tplg_dbg("\t%s: %d", id, be->mask); in tplg_parse_control_bytes()
511 return -EINVAL; in tplg_parse_control_bytes()
524 &be->hdr); in tplg_parse_control_bytes()
539 err = parse_access(cfg, &be->hdr); in tplg_parse_control_bytes()
550 be->hdr.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; in tplg_parse_control_bytes()
552 be->hdr.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; in tplg_parse_control_bytes()
563 struct snd_soc_tplg_bytes_control *be = elem->bytes_ext; in tplg_save_control_bytes()
571 err = tplg_save_printf(dst, NULL, "'%s' {\n", elem->id); in tplg_save_control_bytes()
574 if (err >= 0 && elem->index > 0) in tplg_save_control_bytes()
575 err = tplg_save_printf(dst, pfx, "\tindex %u\n", elem->index); in tplg_save_control_bytes()
576 if (err >= 0 && be->base > 0) in tplg_save_control_bytes()
577 err = tplg_save_printf(dst, pfx, "\tbase %u\n", be->base); in tplg_save_control_bytes()
578 if (err >= 0 && be->num_regs > 0) in tplg_save_control_bytes()
579 err = tplg_save_printf(dst, pfx, "\tnum_regs %u\n", be->num_regs); in tplg_save_control_bytes()
580 if (err >= 0 && be->max > 0) in tplg_save_control_bytes()
581 err = tplg_save_printf(dst, pfx, "\tmax %u\n", be->max); in tplg_save_control_bytes()
582 if (err >= 0 && be->mask > 0) in tplg_save_control_bytes()
583 err = tplg_save_printf(dst, pfx, "\tmask %u\n", be->mask); in tplg_save_control_bytes()
585 err = tplg_save_ops(tplg, &be->hdr, dst, pfx2); in tplg_save_control_bytes()
589 err = tplg_save_access(tplg, &be->hdr, dst, pfx2); in tplg_save_control_bytes()
615 return -ENOMEM; in tplg_parse_control_enum()
617 ec = elem->enum_ctrl; in tplg_parse_control_enum()
618 snd_strlcpy(ec->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); in tplg_parse_control_enum()
619 ec->hdr.type = SND_SOC_TPLG_TYPE_ENUM; in tplg_parse_control_enum()
620 ec->size = elem->size; in tplg_parse_control_enum()
621 tplg->channel_idx = 0; in tplg_parse_control_enum()
625 ec->channel[j].reg = -1; in tplg_parse_control_enum()
628 tplg_dbg(" Control Enum: %s", elem->id); in tplg_parse_control_enum()
644 return -EINVAL; in tplg_parse_control_enum()
652 if (ec->num_channels >= SND_SOC_TPLG_MAX_CHAN) { in tplg_parse_control_enum()
653 SNDERR("too many channels %s", elem->id); in tplg_parse_control_enum()
654 return -EINVAL; in tplg_parse_control_enum()
658 ec->channel); in tplg_parse_control_enum()
662 ec->num_channels = tplg->channel_idx; in tplg_parse_control_enum()
668 &ec->hdr); in tplg_parse_control_enum()
682 err = parse_access(cfg, &ec->hdr); in tplg_parse_control_enum()
692 ec->hdr.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; in tplg_parse_control_enum()
703 struct snd_soc_tplg_enum_control *ec = elem->enum_ctrl; in tplg_save_control_enum()
711 err = tplg_save_printf(dst, NULL, "'%s' {\n", elem->id); in tplg_save_control_enum()
714 if (err >= 0 && elem->index > 0) in tplg_save_control_enum()
715 err = tplg_save_printf(dst, pfx, "\tindex %u\n", elem->index); in tplg_save_control_enum()
720 err = tplg_save_channels(tplg, ec->channel, ec->num_channels, in tplg_save_control_enum()
723 err = tplg_save_ops(tplg, &ec->hdr, dst, pfx2); in tplg_save_control_enum()
725 err = tplg_save_access(tplg, &ec->hdr, dst, pfx2); in tplg_save_control_enum()
752 return -ENOMEM; in tplg_parse_control_mixer()
755 mc = elem->mixer_ctrl; in tplg_parse_control_mixer()
756 snd_strlcpy(mc->hdr.name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); in tplg_parse_control_mixer()
757 mc->hdr.type = SND_SOC_TPLG_TYPE_MIXER; in tplg_parse_control_mixer()
758 mc->size = elem->size; in tplg_parse_control_mixer()
759 tplg->channel_idx = 0; in tplg_parse_control_mixer()
763 mc->channel[j].reg = -1; in tplg_parse_control_mixer()
765 tplg_dbg(" Control Mixer: %s", elem->id); in tplg_parse_control_mixer()
780 if (mc->num_channels >= SND_SOC_TPLG_MAX_CHAN) { in tplg_parse_control_mixer()
781 SNDERR("too many channels %s", elem->id); in tplg_parse_control_mixer()
782 return -EINVAL; in tplg_parse_control_mixer()
786 mc->channel); in tplg_parse_control_mixer()
790 mc->num_channels = tplg->channel_idx; in tplg_parse_control_mixer()
796 return -EINVAL; in tplg_parse_control_mixer()
798 mc->max = ival; in tplg_parse_control_mixer()
799 tplg_dbg("\t%s: %d", id, mc->max); in tplg_parse_control_mixer()
806 return -EINVAL; in tplg_parse_control_mixer()
807 mc->invert = ival; in tplg_parse_control_mixer()
809 tplg_dbg("\t%s: %d", id, mc->invert); in tplg_parse_control_mixer()
815 &mc->hdr); in tplg_parse_control_mixer()
823 return -EINVAL; in tplg_parse_control_mixer()
842 err = parse_access(cfg, &mc->hdr); in tplg_parse_control_mixer()
853 mc->hdr.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; in tplg_parse_control_mixer()
855 mc->hdr.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; in tplg_parse_control_mixer()
865 struct snd_soc_tplg_mixer_control *mc = elem->mixer_ctrl; in tplg_save_control_mixer()
871 err = tplg_save_printf(dst, NULL, "'%s' {\n", elem->id); in tplg_save_control_mixer()
875 if (err >= 0 && elem->index > 0) in tplg_save_control_mixer()
876 err = tplg_save_printf(dst, pfx, "\tindex %u\n", elem->index); in tplg_save_control_mixer()
878 err = tplg_save_channels(tplg, mc->channel, mc->num_channels, in tplg_save_control_mixer()
880 if (err >= 0 && mc->max > 0) in tplg_save_control_mixer()
881 err = tplg_save_printf(dst, pfx, "\tmax %u\n", mc->max); in tplg_save_control_mixer()
882 if (err >= 0 && mc->invert > 0) in tplg_save_control_mixer()
884 if (err >= 0 && mc->invert > 0) in tplg_save_control_mixer()
887 err = tplg_save_ops(tplg, &mc->hdr, dst, pfx2); in tplg_save_control_mixer()
889 err = tplg_save_access(tplg, &mc->hdr, dst, pfx2); in tplg_save_control_mixer()
909 hdr->size = sizeof(struct snd_soc_tplg_ctl_hdr); in init_ctl_hdr()
910 hdr->type = t->type; in init_ctl_hdr()
912 snd_strlcpy(hdr->name, t->name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN); in init_ctl_hdr()
915 if (t->access == 0) in init_ctl_hdr()
916 t->access = SNDRV_CTL_ELEM_ACCESS_READWRITE; in init_ctl_hdr()
917 t->access &= (SNDRV_CTL_ELEM_ACCESS_READWRITE | in init_ctl_hdr()
924 hdr->access = t->access; in init_ctl_hdr()
925 hdr->ops.get = t->ops.get; in init_ctl_hdr()
926 hdr->ops.put = t->ops.put; in init_ctl_hdr()
927 hdr->ops.info = t->ops.info; in init_ctl_hdr()
930 if (hdr->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE in init_ctl_hdr()
931 && !(hdr->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)) { in init_ctl_hdr()
933 struct snd_tplg_tlv_template *tlvt = t->tlv; in init_ctl_hdr()
940 return -EINVAL; in init_ctl_hdr()
943 elem = tplg_elem_new_common(tplg, NULL, parent->id, in init_ctl_hdr()
946 return -ENOMEM; in init_ctl_hdr()
948 tlv = elem->tlv; in init_ctl_hdr()
950 err = tplg_ref_add(parent, SND_TPLG_TYPE_TLV, parent->id); in init_ctl_hdr()
954 tlv->size = sizeof(struct snd_soc_tplg_ctl_tlv); in init_ctl_hdr()
955 tlv->type = tlvt->type; in init_ctl_hdr()
957 switch (tlvt->type) { in init_ctl_hdr()
961 scale = &tlv->scale; in init_ctl_hdr()
962 scale->min = scalet->min; in init_ctl_hdr()
963 scale->step = scalet->step; in init_ctl_hdr()
964 scale->mute = scalet->mute; in init_ctl_hdr()
969 SNDERR("unsupported TLV type %d", tlv->type); in init_ctl_hdr()
985 tplg_dbg(" Control Mixer: %s", mixer->hdr.name); in tplg_add_mixer()
987 if (mixer->hdr.type != SND_SOC_TPLG_TYPE_MIXER) { in tplg_add_mixer()
988 SNDERR("invalid mixer type %d", mixer->hdr.type); in tplg_add_mixer()
989 return -EINVAL; in tplg_add_mixer()
992 elem = tplg_elem_new_common(tplg, NULL, mixer->hdr.name, in tplg_add_mixer()
995 return -ENOMEM; in tplg_add_mixer()
998 mc = elem->mixer_ctrl; in tplg_add_mixer()
999 mc->size = elem->size; in tplg_add_mixer()
1000 ret = init_ctl_hdr(tplg, elem, &mc->hdr, &mixer->hdr); in tplg_add_mixer()
1006 mc->min = mixer->min; in tplg_add_mixer()
1007 mc->max = mixer->max; in tplg_add_mixer()
1008 mc->platform_max = mixer->platform_max; in tplg_add_mixer()
1009 mc->invert = mixer->invert; in tplg_add_mixer()
1013 mc->channel[i].reg = -1; in tplg_add_mixer()
1015 num_channels = mixer->map ? mixer->map->num_channels : 0; in tplg_add_mixer()
1016 mc->num_channels = num_channels; in tplg_add_mixer()
1019 struct snd_tplg_channel_elem *channel = &mixer->map->channel[i]; in tplg_add_mixer()
1021 mc->channel[i].size = sizeof(mc->channel[0]); in tplg_add_mixer()
1022 mc->channel[i].reg = channel->reg; in tplg_add_mixer()
1023 mc->channel[i].shift = channel->shift; in tplg_add_mixer()
1024 mc->channel[i].id = channel->id; in tplg_add_mixer()
1028 priv = mixer->priv; in tplg_add_mixer()
1029 if (priv && priv->size > 0) { in tplg_add_mixer()
1031 sizeof(*priv) + priv->size); in tplg_add_mixer()
1049 tplg_dbg(" Control Enum: %s", enum_ctl->hdr.name); in tplg_add_enum()
1051 if (enum_ctl->hdr.type != SND_SOC_TPLG_TYPE_ENUM) { in tplg_add_enum()
1052 SNDERR("invalid enum type %d", enum_ctl->hdr.type); in tplg_add_enum()
1053 return -EINVAL; in tplg_add_enum()
1056 elem = tplg_elem_new_common(tplg, NULL, enum_ctl->hdr.name, in tplg_add_enum()
1059 return -ENOMEM; in tplg_add_enum()
1061 ec = elem->enum_ctrl; in tplg_add_enum()
1062 ec->size = elem->size; in tplg_add_enum()
1063 ret = init_ctl_hdr(tplg, elem, &ec->hdr, &enum_ctl->hdr); in tplg_add_enum()
1069 num_items = enum_ctl->items < SND_SOC_TPLG_NUM_TEXTS ? in tplg_add_enum()
1070 enum_ctl->items : SND_SOC_TPLG_NUM_TEXTS; in tplg_add_enum()
1071 ec->items = num_items; in tplg_add_enum()
1072 ec->mask = enum_ctl->mask; in tplg_add_enum()
1073 ec->count = enum_ctl->items; in tplg_add_enum()
1077 ec->channel[i].reg = -1; in tplg_add_enum()
1079 num_channels = enum_ctl->map ? enum_ctl->map->num_channels : 0; in tplg_add_enum()
1080 ec->num_channels = num_channels; in tplg_add_enum()
1083 struct snd_tplg_channel_elem *channel = &enum_ctl->map->channel[i]; in tplg_add_enum()
1085 ec->channel[i].size = sizeof(ec->channel[0]); in tplg_add_enum()
1086 ec->channel[i].reg = channel->reg; in tplg_add_enum()
1087 ec->channel[i].shift = channel->shift; in tplg_add_enum()
1088 ec->channel[i].id = channel->id; in tplg_add_enum()
1091 if (enum_ctl->texts != NULL) { in tplg_add_enum()
1093 enum_ctl->hdr.name, SND_TPLG_TYPE_TEXT); in tplg_add_enum()
1095 texts->texts->num_items = num_items; in tplg_add_enum()
1097 if (!enum_ctl->texts[i]) in tplg_add_enum()
1099 snd_strlcpy(ec->texts[i], enum_ctl->texts[i], in tplg_add_enum()
1101 snd_strlcpy(texts->texts->items[i], enum_ctl->texts[i], in tplg_add_enum()
1104 tplg_ref_add(elem, SND_TPLG_TYPE_TEXT, enum_ctl->hdr.name); in tplg_add_enum()
1107 if (enum_ctl->values != NULL) { in tplg_add_enum()
1109 if (enum_ctl->values[i] == NULL) in tplg_add_enum()
1112 memcpy(&ec->values[i * sizeof(int) * ENUM_VAL_SIZE], in tplg_add_enum()
1113 enum_ctl->values[i], in tplg_add_enum()
1119 priv = enum_ctl->priv; in tplg_add_enum()
1120 if (priv && priv->size > 0) { in tplg_add_enum()
1122 sizeof(*priv) + priv->size); in tplg_add_enum()
1140 tplg_dbg(" Control Bytes: %s", bytes_ctl->hdr.name); in tplg_add_bytes()
1142 if (bytes_ctl->hdr.type != SND_SOC_TPLG_TYPE_BYTES) { in tplg_add_bytes()
1143 SNDERR("invalid bytes type %d", bytes_ctl->hdr.type); in tplg_add_bytes()
1144 return -EINVAL; in tplg_add_bytes()
1147 elem = tplg_elem_new_common(tplg, NULL, bytes_ctl->hdr.name, in tplg_add_bytes()
1150 return -ENOMEM; in tplg_add_bytes()
1152 be = elem->bytes_ext; in tplg_add_bytes()
1153 be->size = elem->size; in tplg_add_bytes()
1154 ret = init_ctl_hdr(tplg, elem, &be->hdr, &bytes_ctl->hdr); in tplg_add_bytes()
1160 be->max = bytes_ctl->max; in tplg_add_bytes()
1161 be->mask = bytes_ctl->mask; in tplg_add_bytes()
1162 be->base = bytes_ctl->base; in tplg_add_bytes()
1163 be->num_regs = bytes_ctl->num_regs; in tplg_add_bytes()
1164 be->ext_ops.put = bytes_ctl->ext_ops.put; in tplg_add_bytes()
1165 be->ext_ops.get = bytes_ctl->ext_ops.get; in tplg_add_bytes()
1168 priv = bytes_ctl->priv; in tplg_add_bytes()
1169 if (priv && priv->size > 0) { in tplg_add_bytes()
1171 sizeof(*priv) + priv->size); in tplg_add_bytes()
1177 if (be->hdr.access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { in tplg_add_bytes()
1178 if ((be->hdr.access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) in tplg_add_bytes()
1181 be->hdr.access); in tplg_add_bytes()
1183 return -EINVAL; in tplg_add_bytes()
1186 if (!be->max) { in tplg_add_bytes()
1188 return -EINVAL; in tplg_add_bytes()
1199 return tplg_add_mixer(tplg, t->mixer, NULL); in tplg_add_mixer_object()
1204 return tplg_add_enum(tplg, t->enum_ctl, NULL); in tplg_add_enum_object()
1209 return tplg_add_bytes(tplg, t->bytes_ctl, NULL); in tplg_add_bytes_object()
1220 struct snd_tplg_tlv_dbscale_template *db; in tplg_decode_control_mixer1() local
1225 return -EINVAL; in tplg_decode_control_mixer1()
1229 mc->size, mc->hdr.tlv.size, mc->priv.size); in tplg_decode_control_mixer1()
1230 if (size != mc->size + mc->priv.size) { in tplg_decode_control_mixer1()
1232 return -EINVAL; in tplg_decode_control_mixer1()
1236 mt->hdr.type = mc->hdr.type; in tplg_decode_control_mixer1()
1237 mt->hdr.name = mc->hdr.name; in tplg_decode_control_mixer1()
1238 mt->hdr.access = mc->hdr.access; in tplg_decode_control_mixer1()
1239 mt->hdr.ops.get = mc->hdr.ops.get; in tplg_decode_control_mixer1()
1240 mt->hdr.ops.put = mc->hdr.ops.put; in tplg_decode_control_mixer1()
1241 mt->hdr.ops.info = mc->hdr.ops.info; in tplg_decode_control_mixer1()
1242 mt->min = mc->min; in tplg_decode_control_mixer1()
1243 mt->max = mc->max; in tplg_decode_control_mixer1()
1244 mt->platform_max = mc->platform_max; in tplg_decode_control_mixer1()
1246 mt->hdr.name, mt->hdr.access); in tplg_decode_control_mixer1()
1247 if (mc->num_channels > 0) { in tplg_decode_control_mixer1()
1249 map->num_channels = mc->num_channels; in tplg_decode_control_mixer1()
1250 for (i = 0; i < map->num_channels; i++) { in tplg_decode_control_mixer1()
1251 map->channel[i].reg = mc->channel[i].reg; in tplg_decode_control_mixer1()
1252 map->channel[i].shift = mc->channel[i].shift; in tplg_decode_control_mixer1()
1253 map->channel[i].id = mc->channel[i].id; in tplg_decode_control_mixer1()
1255 mt->map = map; in tplg_decode_control_mixer1()
1257 if (mc->hdr.tlv.size == 0) { in tplg_decode_control_mixer1()
1259 } else if (mc->hdr.tlv.size == sizeof(struct snd_soc_tplg_ctl_tlv)) { in tplg_decode_control_mixer1()
1260 if (mc->hdr.tlv.type != SNDRV_CTL_TLVT_DB_SCALE) { in tplg_decode_control_mixer1()
1262 mc->hdr.tlv.type); in tplg_decode_control_mixer1()
1263 return -EINVAL; in tplg_decode_control_mixer1()
1265 db = tplg_calloc(heap, sizeof(*db)); in tplg_decode_control_mixer1()
1266 if (db == NULL) in tplg_decode_control_mixer1()
1267 return -ENOMEM; in tplg_decode_control_mixer1()
1268 mt->hdr.tlv_scale = db; in tplg_decode_control_mixer1()
1269 db->hdr.type = mc->hdr.tlv.type; in tplg_decode_control_mixer1()
1270 db->min = mc->hdr.tlv.scale.min; in tplg_decode_control_mixer1()
1271 db->step = mc->hdr.tlv.scale.step; in tplg_decode_control_mixer1()
1272 db->mute = mc->hdr.tlv.scale.mute; in tplg_decode_control_mixer1()
1273 tplg_log(tplg, 'D', pos, "mixer: dB scale TLV: min %d step %d mute %d", in tplg_decode_control_mixer1()
1274 db->min, db->step, db->mute); in tplg_decode_control_mixer1()
1276 SNDERR("mixer: wrong TLV size %d", mc->hdr.tlv.size); in tplg_decode_control_mixer1()
1277 return -EINVAL; in tplg_decode_control_mixer1()
1280 mt->priv = &mc->priv; in tplg_decode_control_mixer1()
1305 return -EINVAL; in tplg_decode_control_mixer()
1309 size2 = mc->size + mc->priv.size; in tplg_decode_control_mixer()
1312 mc->size, mc->priv.size); in tplg_decode_control_mixer()
1313 return -EINVAL; in tplg_decode_control_mixer()
1326 size -= size2; in tplg_decode_control_mixer()
1343 if (ec->num_channels > SND_TPLG_MAX_CHAN || in tplg_decode_control_enum1()
1344 ec->num_channels > SND_SOC_TPLG_MAX_CHAN) { in tplg_decode_control_enum1()
1345 SNDERR("enum: unexpected channel count %d", ec->num_channels); in tplg_decode_control_enum1()
1346 return -EINVAL; in tplg_decode_control_enum1()
1348 if (ec->items > SND_SOC_TPLG_NUM_TEXTS) { in tplg_decode_control_enum1()
1349 SNDERR("enum: unexpected texts count %d", ec->items); in tplg_decode_control_enum1()
1350 return -EINVAL; in tplg_decode_control_enum1()
1354 et->hdr.type = ec->hdr.type; in tplg_decode_control_enum1()
1355 et->hdr.name = ec->hdr.name; in tplg_decode_control_enum1()
1356 et->hdr.access = ec->hdr.access; in tplg_decode_control_enum1()
1357 et->hdr.ops.get = ec->hdr.ops.get; in tplg_decode_control_enum1()
1358 et->hdr.ops.put = ec->hdr.ops.put; in tplg_decode_control_enum1()
1359 et->hdr.ops.info = ec->hdr.ops.info; in tplg_decode_control_enum1()
1360 et->mask = ec->mask; in tplg_decode_control_enum1()
1362 if (ec->items > 0) { in tplg_decode_control_enum1()
1363 et->items = ec->items; in tplg_decode_control_enum1()
1364 et->texts = tplg_calloc(heap, sizeof(char *) * ec->items); in tplg_decode_control_enum1()
1365 if (!et->texts) in tplg_decode_control_enum1()
1366 return -ENOMEM; in tplg_decode_control_enum1()
1367 for (i = 0; (unsigned int)i < ec->items; i++) in tplg_decode_control_enum1()
1368 et->texts[i] = ec->texts[i]; in tplg_decode_control_enum1()
1371 et->map = tplg_calloc(heap, sizeof(struct snd_tplg_channel_map_template)); in tplg_decode_control_enum1()
1372 if (!et->map) in tplg_decode_control_enum1()
1373 return -ENOMEM; in tplg_decode_control_enum1()
1374 et->map->num_channels = ec->num_channels; in tplg_decode_control_enum1()
1375 for (i = 0; i < et->map->num_channels; i++) { in tplg_decode_control_enum1()
1376 struct snd_tplg_channel_elem *channel = &et->map->channel[i]; in tplg_decode_control_enum1()
1378 tplg_log(tplg, 'D', pos + ((void *)&ec->channel[i] - (void *)ec), in tplg_decode_control_enum1()
1379 "enum: channel size %d", ec->channel[i].size); in tplg_decode_control_enum1()
1380 channel->reg = ec->channel[i].reg; in tplg_decode_control_enum1()
1381 channel->shift = ec->channel[i].shift; in tplg_decode_control_enum1()
1382 channel->id = ec->channel[i].id; in tplg_decode_control_enum1()
1385 et->priv = &ec->priv; in tplg_decode_control_enum1()
1408 return -EINVAL; in tplg_decode_control_enum()
1412 size2 = ec->size + ec->priv.size; in tplg_decode_control_enum()
1415 ec->size, ec->priv.size); in tplg_decode_control_enum()
1416 return -EINVAL; in tplg_decode_control_enum()
1420 ec->size, ec->priv.size); in tplg_decode_control_enum()
1432 size -= size2; in tplg_decode_control_enum()
1450 return -EINVAL; in tplg_decode_control_bytes1()
1454 bc->size, bc->priv.size); in tplg_decode_control_bytes1()
1455 if (size != bc->size + bc->priv.size) { in tplg_decode_control_bytes1()
1457 return -EINVAL; in tplg_decode_control_bytes1()
1461 bt->hdr.type = bc->hdr.type; in tplg_decode_control_bytes1()
1462 bt->hdr.name = bc->hdr.name; in tplg_decode_control_bytes1()
1463 bt->hdr.access = bc->hdr.access; in tplg_decode_control_bytes1()
1464 bt->hdr.ops.get = bc->hdr.ops.get; in tplg_decode_control_bytes1()
1465 bt->hdr.ops.put = bc->hdr.ops.put; in tplg_decode_control_bytes1()
1466 bt->hdr.ops.info = bc->hdr.ops.info; in tplg_decode_control_bytes1()
1467 bt->max = bc->max; in tplg_decode_control_bytes1()
1468 bt->mask = bc->mask; in tplg_decode_control_bytes1()
1469 bt->base = bc->base; in tplg_decode_control_bytes1()
1470 bt->num_regs = bc->num_regs; in tplg_decode_control_bytes1()
1471 bt->ext_ops.get = bc->ext_ops.get; in tplg_decode_control_bytes1()
1472 bt->ext_ops.put = bc->ext_ops.put; in tplg_decode_control_bytes1()
1473 bt->ext_ops.info = bc->ext_ops.info; in tplg_decode_control_bytes1()
1475 bt->hdr.name, bt->hdr.access); in tplg_decode_control_bytes1()
1477 bt->priv = &bc->priv; in tplg_decode_control_bytes1()
1499 return -EINVAL; in tplg_decode_control_bytes()
1502 size2 = bc->size + bc->priv.size; in tplg_decode_control_bytes()
1505 bc->size, bc->priv.size); in tplg_decode_control_bytes()
1506 return -EINVAL; in tplg_decode_control_bytes()
1519 size -= size2; in tplg_decode_control_bytes()