Commit 82ed7418 authored by Keyon Jie's avatar Keyon Jie Committed by Mark Brown

ASoC: topology: refine and log the header in the correct pass

The check (tplg->pass == le32_to_cpu(hdr->type)) makes no sense as it is
comparing two different enums, refine the element loading functions, and
log the information when the header is being parsed in the corresponding
parsing pass.
Signed-off-by: default avatarKeyon Jie <yang.jie@linux.intel.com>
Tested-by: default avatarVamshi Kerishna Gopal <vamshi.krishna.gopal@intel.com>
Tested-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200527022801.336264-2-yang.jie@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4a043450
......@@ -2685,12 +2685,6 @@ static int soc_valid_header(struct soc_tplg *tplg,
return -EINVAL;
}
if (tplg->pass == le32_to_cpu(hdr->type))
dev_dbg(tplg->dev,
"ASoC: Got 0x%x bytes of type %d version %d vendor %d at pass %d\n",
hdr->payload_size, hdr->type, hdr->version,
hdr->vendor_type, tplg->pass);
return 1;
}
......@@ -2698,6 +2692,10 @@ static int soc_valid_header(struct soc_tplg *tplg,
static int soc_tplg_load_header(struct soc_tplg *tplg,
struct snd_soc_tplg_hdr *hdr)
{
int (*elem_load)(struct soc_tplg *tplg,
struct snd_soc_tplg_hdr *hdr);
unsigned int hdr_pass;
tplg->pos = tplg->hdr_pos + sizeof(struct snd_soc_tplg_hdr);
/* check for matching ID */
......@@ -2711,24 +2709,48 @@ static int soc_tplg_load_header(struct soc_tplg *tplg,
case SND_SOC_TPLG_TYPE_MIXER:
case SND_SOC_TPLG_TYPE_ENUM:
case SND_SOC_TPLG_TYPE_BYTES:
return soc_tplg_kcontrol_elems_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_MIXER;
elem_load = soc_tplg_kcontrol_elems_load;
break;
case SND_SOC_TPLG_TYPE_DAPM_GRAPH:
return soc_tplg_dapm_graph_elems_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_GRAPH;
elem_load = soc_tplg_dapm_graph_elems_load;
break;
case SND_SOC_TPLG_TYPE_DAPM_WIDGET:
return soc_tplg_dapm_widget_elems_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_WIDGET;
elem_load = soc_tplg_dapm_widget_elems_load;
break;
case SND_SOC_TPLG_TYPE_PCM:
return soc_tplg_pcm_elems_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_PCM_DAI;
elem_load = soc_tplg_pcm_elems_load;
break;
case SND_SOC_TPLG_TYPE_DAI:
return soc_tplg_dai_elems_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_BE_DAI;
elem_load = soc_tplg_dai_elems_load;
break;
case SND_SOC_TPLG_TYPE_DAI_LINK:
case SND_SOC_TPLG_TYPE_BACKEND_LINK:
/* physical link configurations */
return soc_tplg_link_elems_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_LINK;
elem_load = soc_tplg_link_elems_load;
break;
case SND_SOC_TPLG_TYPE_MANIFEST:
return soc_tplg_manifest_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_MANIFEST;
elem_load = soc_tplg_manifest_load;
break;
default:
/* bespoke vendor data object */
return soc_tplg_vendor_load(tplg, hdr);
hdr_pass = SOC_TPLG_PASS_VENDOR;
elem_load = soc_tplg_vendor_load;
break;
}
if (tplg->pass == hdr_pass) {
dev_dbg(tplg->dev,
"ASoC: Got 0x%x bytes of type %d version %d vendor %d at pass %d\n",
hdr->payload_size, hdr->type, hdr->version,
hdr->vendor_type, tplg->pass);
return elem_load(tplg, hdr);
}
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment