Message ID | 1438708186-16263-1-git-send-email-liam.r.girdwood@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, 04 Aug 2015 19:09:46 +0200, Liam Girdwood wrote: > > From: Mengdong Lin <mengdong.lin@intel.com> > > 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> Applied, thanks. Takashi > --- > src/topology/builder.c | 37 ++++++++++++++++++++++++++++++++----- > src/topology/tplg_local.h | 1 + > 2 files changed, 33 insertions(+), 5 deletions(-) > > diff --git a/src/topology/builder.c b/src/topology/builder.c > index 0066b22..a944866 100644 > --- a/src/topology/builder.c > +++ b/src/topology/builder.c > @@ -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; > diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h > index 62788e4..ad38945 100644 > --- a/src/topology/tplg_local.h > +++ b/src/topology/tplg_local.h > @@ -77,6 +77,7 @@ struct snd_tplg { > > /* manifest */ > struct snd_soc_tplg_manifest manifest; > + const void *manifest_pdata; /* copied by builder at file write */ > > /* list of each element type */ > struct list_head tlv_list; > -- > 2.1.4 >
diff --git a/src/topology/builder.c b/src/topology/builder.c index 0066b22..a944866 100644 --- a/src/topology/builder.c +++ b/src/topology/builder.c @@ -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; diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index 62788e4..ad38945 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -77,6 +77,7 @@ struct snd_tplg { /* manifest */ struct snd_soc_tplg_manifest manifest; + const void *manifest_pdata; /* copied by builder at file write */ /* list of each element type */ struct list_head tlv_list;