[PATCH 16/22] topology: Parse and build private data of physical links

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mengdong Lin <mengdong.lin@xxxxxxxxxxxxxxx>

Users can define private data for physical links by C API or text conf
file.

Signed-off-by: Mengdong Lin <mengdong.lin@xxxxxxxxxxxxxxx>

diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index daeb32e..c4857ba 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -162,7 +162,7 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem)
 	if (err < 0)
 		return err;
 
-	/* hw configs */
+	/* hw configs & private data */
 	base = &elem->ref_list;
 	list_for_each(pos, base) {
 
@@ -185,6 +185,12 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem)
 			num_hw_configs++;
 			break;
 
+		case SND_TPLG_TYPE_DATA: /* merge private data */
+			err = tplg_copy_data(tplg, elem, ref);
+			if (err < 0)
+				return err;
+			break;
+
 		default:
 			break;
 		}
@@ -1079,5 +1085,24 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 	/* flags */
 	link->flag_mask = link_tpl->flag_mask;
 	link->flags = link_tpl->flags;
+
+	/* private data */
+	if (link_tpl->priv != NULL && link_tpl->priv->size) {
+		_link = realloc(link,
+			elem->size + link_tpl->priv->size);
+		if (!_link) {
+			tplg_elem_free(elem);
+			return -ENOMEM;
+		}
+
+		link = _link;
+		elem->link = link;
+		elem->size += link_tpl->priv->size;
+
+		memcpy(link->priv.data, link_tpl->priv->data,
+			link_tpl->priv->size);
+		link->priv.size = link_tpl->priv->size;
+	}
+
 	return 0;
 }
-- 
2.5.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux