topology: A API calls to directly build topology data from templates

Add some new API calls so that applications can directly build topology data
using template structures.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Mengdong Lin 2015-08-11 18:23:17 +01:00 committed by Takashi Iwai
parent 1b148ef590
commit 5b518c9159
6 changed files with 573 additions and 18 deletions

View file

@ -266,11 +266,8 @@ int snd_tplg_build_file(snd_tplg_t *tplg, const char *infile,
snd_config_t *cfg = NULL;
int err = 0;
/* delete any old output files */
unlink(outfile);
tplg->out_fd =
open(outfile, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (tplg->out_fd < 0) {
SNDERR("error: failed to open %s err %d\n",
outfile, -errno);
@ -309,6 +306,60 @@ out_close:
return err;
}
int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
{
switch (t->type) {
case SND_TPLG_TYPE_MIXER:
return tplg_add_mixer_object(tplg, t);
case SND_TPLG_TYPE_ENUM:
return tplg_add_enum_object(tplg, t);
case SND_TPLG_TYPE_BYTES:
return tplg_add_bytes_object(tplg, t);
case SND_TPLG_TYPE_DAPM_WIDGET:
return tplg_add_widget_object(tplg, t);
case SND_TPLG_TYPE_DAPM_GRAPH:
return tplg_add_graph_object(tplg, t);
default:
SNDERR("error: invalid object type %d\n", t->type);
return -EINVAL;
};
}
int snd_tplg_build(snd_tplg_t *tplg, const char *outfile)
{
int err;
tplg->out_fd =
open(outfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (tplg->out_fd < 0) {
SNDERR("error: failed to open %s err %d\n",
outfile, -errno);
return -errno;
}
err = tplg_build_integ(tplg);
if (err < 0) {
SNDERR("error: failed to check topology integrity\n");
goto out;
}
err = tplg_write_data(tplg);
if (err < 0) {
SNDERR("error: failed to write data %d\n", err);
goto out;
}
out:
close(tplg->out_fd);
return err;
}
int snd_tplg_set_manifest_data(snd_tplg_t *tplg, const void *data, int len)
{
tplg->manifest.priv.size = len;
tplg->manifest_pdata = data;
}
void snd_tplg_verbose(snd_tplg_t *tplg, int verbose)
{
tplg->verbose = verbose;