diff --git a/asoc/holi.c b/asoc/holi.c index b9cfbf7cf8..8c3bdbf24d 100644 --- a/asoc/holi.c +++ b/asoc/holi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -6602,6 +6603,49 @@ static int msm_audio_ssr_register(struct device *dev) return ret; } +static int msm_asoc_parse_soundcard_name(struct platform_device *pdev, + struct snd_soc_card *card) +{ + struct nvmem_cell *cell; + size_t len; + u32 *buf; + u32 adsp_var_idx = 0; + int ret = 0; + + /* get adsp variant idx */ + cell = nvmem_cell_get(&pdev->dev, "adsp_variant"); + if (IS_ERR_OR_NULL(cell)) { + dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n", __func__); + goto parse; + } + buf = nvmem_cell_read(cell, &len); + nvmem_cell_put(cell); + if (IS_ERR_OR_NULL(buf)) { + dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell \n", __func__); + goto parse; + } + if (len <= 0 || len > sizeof(u32)) { + dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n", + __func__, len); + kfree(buf); + goto parse; + } + memcpy(&adsp_var_idx, buf, len); + kfree(buf); + +parse: + if(adsp_var_idx == 1) + ret = snd_soc_of_parse_card_name(card, "qcom,sku-model"); + else + ret = snd_soc_of_parse_card_name(card, "qcom,model"); + + if (ret) + dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n", + __func__, ret); + + return ret; +} + static int msm_asoc_machine_probe(struct platform_device *pdev) { struct snd_soc_card *card = NULL; @@ -6637,9 +6681,9 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, pdata); - ret = snd_soc_of_parse_card_name(card, "qcom,model"); + ret = msm_asoc_parse_soundcard_name(pdev, card); if (ret) { - dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n", + dev_err(&pdev->dev, "%s: parse soundcard name failed, err:%d\n", __func__, ret); goto err; }