summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMengdong Lin <mengdong.lin@linux.intel.com>2016-11-24 09:34:00 +0800
committerTakashi Iwai <tiwai@suse.de>2016-11-24 14:20:22 +0100
commitf53ff68562d68057860562dc63ad80b4ffa191e1 (patch)
treeea94e15d169baa0679ee736f44a61d44782a9c1f
parentf9633ed8520dd9a4cce81337173087d03521da6d (diff)
downloadalsa-lib-f53ff68562d68057860562dc63ad80b4ffa191e1.tar.gz
topology: Store number of strings of a text section
Enum controls may use text elements and need the number of strings. This patch adds a text child object for a generic element. When parsing a text section from the configuation file, store the text strings and number of strings (num_items) in the text child object of the element. Reported-by: G Kranthi <gudishax.kranthikumar@intel.com> Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--src/topology/ctl.c4
-rw-r--r--src/topology/elem.c1
-rw-r--r--src/topology/text.c6
-rw-r--r--src/topology/tplg_local.h9
4 files changed, 14 insertions, 6 deletions
diff --git a/src/topology/ctl.c b/src/topology/ctl.c
index 54f8e444..907a97f9 100644
--- a/src/topology/ctl.c
+++ b/src/topology/ctl.c
@@ -159,9 +159,11 @@ static void copy_enum_texts(struct tplg_elem *enum_elem,
struct tplg_elem *ref_elem)
{
struct snd_soc_tplg_enum_control *ec = enum_elem->enum_ctrl;
+ struct tplg_texts *texts = ref_elem->texts;
- memcpy(ec->texts, ref_elem->texts,
+ memcpy(ec->texts, texts->items,
SND_SOC_TPLG_NUM_TEXTS * SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+ ec->items += texts->num_items;
}
/* check referenced text for a enum control */
diff --git a/src/topology/elem.c b/src/topology/elem.c
index 1a5ac841..db264831 100644
--- a/src/topology/elem.c
+++ b/src/topology/elem.c
@@ -159,6 +159,7 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
break;
case SND_TPLG_TYPE_TEXT:
list_add_tail(&elem->list, &tplg->text_list);
+ obj_size = sizeof(struct tplg_texts);
break;
case SND_TPLG_TYPE_TLV:
list_add_tail(&elem->list, &tplg->tlv_list);
diff --git a/src/topology/text.c b/src/topology/text.c
index 0c6594a1..303fbebb 100644
--- a/src/topology/text.c
+++ b/src/topology/text.c
@@ -25,6 +25,7 @@
static int parse_text_values(snd_config_t *cfg, struct tplg_elem *elem)
{
+ struct tplg_texts *texts = elem->texts;
snd_config_iterator_t i, next;
snd_config_t *n;
const char *value = NULL;
@@ -44,13 +45,14 @@ static int parse_text_values(snd_config_t *cfg, struct tplg_elem *elem)
if (snd_config_get_string(n, &value) < 0)
continue;
- elem_copy_text(&elem->texts[j][0], value,
+ elem_copy_text(&texts->items[j][0], value,
SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
- tplg_dbg("\t%s\n", &elem->texts[j][0]);
+ tplg_dbg("\t%s\n", &texts->items[j][0]);
j++;
}
+ texts->num_items = j;
return 0;
}
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h
index f913563a..eb2f7bd4 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -91,6 +91,11 @@ struct tplg_ref {
struct list_head list;
};
+struct tplg_texts {
+ unsigned int num_items;
+ char items[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
+};
+
/* element for vendor tokens */
struct tplg_token {
char id[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
@@ -128,9 +133,6 @@ struct tplg_elem {
char id[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
- /* storage for texts and data if this is text or data elem*/
- char texts[SND_SOC_TPLG_NUM_TEXTS][SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
-
int index;
enum snd_tplg_type type;
@@ -155,6 +157,7 @@ struct tplg_elem {
/* these do not map to UAPI structs but are internal only */
struct snd_soc_tplg_ctl_tlv *tlv;
+ struct tplg_texts *texts;
struct snd_soc_tplg_private *data;
struct tplg_vendor_tokens *tokens;
struct tplg_vendor_tuples *tuples;