topology: Add support for writing manifest private data.

Allow manifest to contain private data and write this data to file.

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-04 18:09:46 +01:00 committed by Takashi Iwai
parent 120b3b8ead
commit d5e7e8bb38
2 changed files with 33 additions and 5 deletions

View file

@ -226,9 +226,6 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base,
case OBJECT_TYPE_CC:
return write_elem_block(tplg, base, size,
SND_SOC_TPLG_TYPE_DAI_LINK, "cc");
case OBJECT_TYPE_MANIFEST:
return write_data_block(tplg, size, SND_SOC_TPLG_TYPE_MANIFEST,
"manifest", &tplg->manifest);
case OBJECT_TYPE_DATA:
return write_elem_block(tplg, base, size,
SND_SOC_TPLG_TYPE_PDATA, "data");
@ -239,13 +236,43 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base,
return 0;
}
/* write the manifest including its private data */
static int write_manifest_data(snd_tplg_t *tplg)
{
int ret;
/* write the header for this block */
ret = write_block_header(tplg, SND_SOC_TPLG_TYPE_MANIFEST, 0,
SND_SOC_TPLG_ABI_VERSION, 0,
sizeof(tplg->manifest) + tplg->manifest.priv.size, 1);
if (ret < 0) {
SNDERR("error: failed to write manifest block %d\n", ret);
return ret;
}
verbose(tplg, "manifest : write %d bytes\n", sizeof(tplg->manifest));
ret = write(tplg->out_fd, &tplg->manifest, sizeof(tplg->manifest));
if (ret < 0) {
SNDERR("error: failed to write manifest %d\n", ret);
return ret;
}
verbose(tplg, "manifest : write %d priv bytes\n", tplg->manifest.priv.size);
ret = write(tplg->out_fd, tplg->manifest_pdata, tplg->manifest.priv.size);
if (ret < 0) {
SNDERR("error: failed to write manifest priv data %d\n", ret);
return ret;
}
return 0;
}
int tplg_write_data(snd_tplg_t *tplg)
{
int ret;
/* write manifest */
ret = write_data_block(tplg, sizeof(tplg->manifest),
OBJECT_TYPE_MANIFEST, "manifest", &tplg->manifest);
ret = write_manifest_data(tplg);
if (ret < 0) {
SNDERR("failed to write manifest %d\n", ret);
return ret;