Merge "asoc: Add support to read adsp variant and set sndcard name"

This commit is contained in:
qctecmdr 2024-03-12 02:41:31 -07:00 committed by Gerrit - the friendly Code Review server
commit 9b78122b3b

View File

@ -19,6 +19,7 @@
#include <linux/soc/qcom/wcd939x-i2c.h>
#endif
#include <linux/pm_qos.h>
#include <linux/nvmem-consumer.h>
#include <sound/control.h>
#include <sound/core.h>
#include <sound/soc.h>
@ -2274,6 +2275,50 @@ void msm_common_set_pdata(struct snd_soc_card *card,
pdata->common_pdata = common_pdata;
}
static int msm_asoc_parse_soundcard_name(struct platform_device *pdev,
struct snd_soc_card *card)
{
struct nvmem_cell *cell = NULL;
size_t len = 0;
u32 *buf = NULL;
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)
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;
@ -2328,9 +2373,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;
}