From 5a56ee6204fd3670494ca7a547176d3bc338b2ff Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Thu, 21 Nov 2019 19:29:22 +0800 Subject: [PATCH] LF-102: ASoC: ak4458: Support DSD512 when codec is ak4497 Support DSD512 when codec is ak4497 Signed-off-by: Shengjiu Wang --- sound/soc/codecs/ak4458.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index c7a693926e9f..48eff8ca722a 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -31,6 +31,7 @@ static const char *ak4458_supply_names[AK4458_NUM_SUPPLIES] = { struct ak4458_drvdata { struct snd_soc_dai_driver *dai_drv; const struct snd_soc_component_driver *comp_drv; + bool dsd512; /* DSD512 is supported or not */ }; /* AK4458 Codec Private Data */ @@ -39,6 +40,7 @@ struct ak4458_priv { struct regmap *regmap; struct gpio_desc *reset_gpiod; struct gpio_desc *mute_gpiod; + const struct ak4458_drvdata *drvdata; int digfil; /* SSLOW, SD, SLOW bits */ int fs; /* sampling rate */ int fmt; @@ -383,8 +385,16 @@ static int ak4458_hw_params(struct snd_pcm_substream *substream, dsdsel0 = 0; dsdsel1 = 1; break; + case 22579200: + if (ak4458->drvdata->dsd512) { + dsdsel0 = 1; + dsdsel1 = 1; + } else { + dev_err(dai->dev, "DSD512 not supported.\n"); + return -EINVAL; + } + break; default: - dev_err(dai->dev, "DSD512 not supported.\n"); return -EINVAL; } @@ -735,11 +745,13 @@ static const struct regmap_config ak4458_regmap = { static const struct ak4458_drvdata ak4458_drvdata = { .dai_drv = &ak4458_dai, .comp_drv = &soc_codec_dev_ak4458, + .dsd512 = false, }; static const struct ak4458_drvdata ak4497_drvdata = { .dai_drv = &ak4497_dai, .comp_drv = &soc_codec_dev_ak4497, + .dsd512 = true, }; static const struct dev_pm_ops ak4458_pm = { @@ -751,7 +763,6 @@ static const struct dev_pm_ops ak4458_pm = { static int ak4458_i2c_probe(struct i2c_client *i2c) { struct ak4458_priv *ak4458; - const struct ak4458_drvdata *drvdata; int ret; int i; @@ -766,7 +777,7 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) i2c_set_clientdata(i2c, ak4458); ak4458->dev = &i2c->dev; - drvdata = of_device_get_match_data(&i2c->dev); + ak4458->drvdata = of_device_get_match_data(&i2c->dev); ak4458->reset_gpiod = devm_gpiod_get_optional(ak4458->dev, "reset", GPIOD_OUT_LOW); @@ -795,8 +806,8 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) return ret; } - ret = devm_snd_soc_register_component(ak4458->dev, drvdata->comp_drv, - drvdata->dai_drv, 1); + ret = devm_snd_soc_register_component(ak4458->dev, ak4458->drvdata->comp_drv, + ak4458->drvdata->dai_drv, 1); if (ret < 0) { dev_err(ak4458->dev, "Failed to register CODEC: %d\n", ret); return ret;