mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	topology: Parse front-end DAI name and ID for the PCM
These two fields are necessary to create the front-end DAIs in kernel but the support is missing in text conf previously. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									5d23c406d1
								
							
						
					
					
						commit
						25d6f8e6a8
					
				
					 2 changed files with 57 additions and 0 deletions
				
			
		| 
						 | 
					@ -533,6 +533,10 @@ extern "C" {
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *	id "0"				# used for binding to the PCM
 | 
					 *	id "0"				# used for binding to the PCM
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 | 
					 *	dai."name of front-end DAI" {
 | 
				
			||||||
 | 
					 *		id "0"		# used for binding to the front-end DAI
 | 
				
			||||||
 | 
					 *	}
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 *	pcm."playback" {
 | 
					 *	pcm."playback" {
 | 
				
			||||||
 *		capabilities "capabilities1"	# capabilities for playback
 | 
					 *		capabilities "capabilities1"	# capabilities for playback
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -320,6 +320,51 @@ static int tplg_parse_streams(snd_tplg_t *tplg, snd_config_t *cfg,
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Parse name and id of a front-end DAI (ie. cpu dai of a FE DAI link) */
 | 
				
			||||||
 | 
					static int tplg_parse_fe_dai(snd_tplg_t *tplg, snd_config_t *cfg,
 | 
				
			||||||
 | 
						void *private)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct tplg_elem *elem = private;
 | 
				
			||||||
 | 
						struct snd_soc_tplg_pcm *pcm = elem->pcm;
 | 
				
			||||||
 | 
						snd_config_iterator_t i, next;
 | 
				
			||||||
 | 
						snd_config_t *n;
 | 
				
			||||||
 | 
						const char *id, *value = NULL;
 | 
				
			||||||
 | 
						unsigned long int id_val;
 | 
				
			||||||
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						snd_config_get_id(cfg, &id);
 | 
				
			||||||
 | 
						tplg_dbg("\t\tFE DAI %s:\n", id);
 | 
				
			||||||
 | 
						elem_copy_text(pcm->dai_name, id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						snd_config_for_each(i, next, cfg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							n = snd_config_iterator_entry(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* get id */
 | 
				
			||||||
 | 
							if (snd_config_get_id(n, &id) < 0)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (strcmp(id, "id") == 0) {
 | 
				
			||||||
 | 
								if (snd_config_get_string(n, &value) < 0)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								errno = 0;
 | 
				
			||||||
 | 
								/* no support for negative value */
 | 
				
			||||||
 | 
								id_val = strtoul(value, NULL, 0);
 | 
				
			||||||
 | 
								if ((errno == ERANGE && id_val == ULONG_MAX)
 | 
				
			||||||
 | 
									|| (errno != 0 && id_val == 0)
 | 
				
			||||||
 | 
									|| id_val > UINT_MAX) {
 | 
				
			||||||
 | 
									SNDERR("error: invalid fe dai ID\n");
 | 
				
			||||||
 | 
									return -EINVAL;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								pcm->dai_id = (int) id_val;
 | 
				
			||||||
 | 
								tplg_dbg("\t\t\tindex: %d\n", pcm->dai_id);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Parse pcm (for front end DAI & DAI link) */
 | 
					/* Parse pcm (for front end DAI & DAI link) */
 | 
				
			||||||
int tplg_parse_pcm(snd_tplg_t *tplg,
 | 
					int tplg_parse_pcm(snd_tplg_t *tplg,
 | 
				
			||||||
	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
 | 
						snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
 | 
				
			||||||
| 
						 | 
					@ -378,6 +423,14 @@ int tplg_parse_pcm(snd_tplg_t *tplg,
 | 
				
			||||||
				return err;
 | 
									return err;
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (strcmp(id, "dai") == 0) {
 | 
				
			||||||
 | 
								err = tplg_parse_compound(tplg, n,
 | 
				
			||||||
 | 
									tplg_parse_fe_dai, elem);
 | 
				
			||||||
 | 
								if (err < 0)
 | 
				
			||||||
 | 
									return err;
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue