mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	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:
		
							parent
							
								
									120b3b8ead
								
							
						
					
					
						commit
						d5e7e8bb38
					
				
					 2 changed files with 33 additions and 5 deletions
				
			
		| 
						 | 
					@ -226,9 +226,6 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base,
 | 
				
			||||||
	case OBJECT_TYPE_CC:
 | 
						case OBJECT_TYPE_CC:
 | 
				
			||||||
		return write_elem_block(tplg, base, size,
 | 
							return write_elem_block(tplg, base, size,
 | 
				
			||||||
			SND_SOC_TPLG_TYPE_DAI_LINK, "cc");
 | 
								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:
 | 
						case OBJECT_TYPE_DATA:
 | 
				
			||||||
		return write_elem_block(tplg, base, size,
 | 
							return write_elem_block(tplg, base, size,
 | 
				
			||||||
			SND_SOC_TPLG_TYPE_PDATA, "data");
 | 
								SND_SOC_TPLG_TYPE_PDATA, "data");
 | 
				
			||||||
| 
						 | 
					@ -239,13 +236,43 @@ static int write_block(snd_tplg_t *tplg, struct list_head *base,
 | 
				
			||||||
	return 0;
 | 
						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 tplg_write_data(snd_tplg_t *tplg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* write manifest */
 | 
						/* write manifest */
 | 
				
			||||||
	ret = write_data_block(tplg, sizeof(tplg->manifest),
 | 
						ret = write_manifest_data(tplg);
 | 
				
			||||||
		OBJECT_TYPE_MANIFEST, "manifest", &tplg->manifest);
 | 
					 | 
				
			||||||
	if (ret < 0) {
 | 
						if (ret < 0) {
 | 
				
			||||||
		SNDERR("failed to write manifest %d\n", ret);
 | 
							SNDERR("failed to write manifest %d\n", ret);
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,7 @@ struct snd_tplg {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* manifest */
 | 
						/* manifest */
 | 
				
			||||||
	struct snd_soc_tplg_manifest manifest;
 | 
						struct snd_soc_tplg_manifest manifest;
 | 
				
			||||||
 | 
						const void *manifest_pdata;	/* copied by builder at file write */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* list of each element type */
 | 
						/* list of each element type */
 | 
				
			||||||
	struct list_head tlv_list;
 | 
						struct list_head tlv_list;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue