|
@@ -38,30 +38,29 @@ static const struct snd_soc_dapm_route ak5386_dapm_routes[] = {
|
|
{ "Capture", NULL, "AINR" },
|
|
{ "Capture", NULL, "AINR" },
|
|
};
|
|
};
|
|
|
|
|
|
-static int ak5386_soc_probe(struct snd_soc_codec *codec)
|
|
|
|
|
|
+static int ak5386_soc_probe(struct snd_soc_component *component)
|
|
{
|
|
{
|
|
- struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
+ struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
|
|
return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
}
|
|
}
|
|
|
|
|
|
-static int ak5386_soc_remove(struct snd_soc_codec *codec)
|
|
|
|
|
|
+static void ak5386_soc_remove(struct snd_soc_component *component)
|
|
{
|
|
{
|
|
- struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
+ struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
|
|
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
- return 0;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
#ifdef CONFIG_PM
|
|
-static int ak5386_soc_suspend(struct snd_soc_codec *codec)
|
|
|
|
|
|
+static int ak5386_soc_suspend(struct snd_soc_component *component)
|
|
{
|
|
{
|
|
- struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
+ struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
|
|
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static int ak5386_soc_resume(struct snd_soc_codec *codec)
|
|
|
|
|
|
+static int ak5386_soc_resume(struct snd_soc_component *component)
|
|
{
|
|
{
|
|
- struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
+ struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
|
|
return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
@@ -69,28 +68,30 @@ static int ak5386_soc_resume(struct snd_soc_codec *codec)
|
|
#define ak5386_soc_resume NULL
|
|
#define ak5386_soc_resume NULL
|
|
#endif /* CONFIG_PM */
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
|
-static const struct snd_soc_codec_driver soc_codec_ak5386 = {
|
|
|
|
- .probe = ak5386_soc_probe,
|
|
|
|
- .remove = ak5386_soc_remove,
|
|
|
|
- .suspend = ak5386_soc_suspend,
|
|
|
|
- .resume = ak5386_soc_resume,
|
|
|
|
- .component_driver = {
|
|
|
|
- .dapm_widgets = ak5386_dapm_widgets,
|
|
|
|
- .num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets),
|
|
|
|
- .dapm_routes = ak5386_dapm_routes,
|
|
|
|
- .num_dapm_routes = ARRAY_SIZE(ak5386_dapm_routes),
|
|
|
|
- },
|
|
|
|
|
|
+static const struct snd_soc_component_driver soc_component_ak5386 = {
|
|
|
|
+ .probe = ak5386_soc_probe,
|
|
|
|
+ .remove = ak5386_soc_remove,
|
|
|
|
+ .suspend = ak5386_soc_suspend,
|
|
|
|
+ .resume = ak5386_soc_resume,
|
|
|
|
+ .dapm_widgets = ak5386_dapm_widgets,
|
|
|
|
+ .num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets),
|
|
|
|
+ .dapm_routes = ak5386_dapm_routes,
|
|
|
|
+ .num_dapm_routes = ARRAY_SIZE(ak5386_dapm_routes),
|
|
|
|
+ .idle_bias_on = 1,
|
|
|
|
+ .use_pmdown_time = 1,
|
|
|
|
+ .endianness = 1,
|
|
|
|
+ .non_legacy_dai_naming = 1,
|
|
};
|
|
};
|
|
|
|
|
|
static int ak5386_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
|
static int ak5386_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
|
unsigned int format)
|
|
unsigned int format)
|
|
{
|
|
{
|
|
- struct snd_soc_codec *codec = codec_dai->codec;
|
|
|
|
|
|
+ struct snd_soc_component *component = codec_dai->component;
|
|
|
|
|
|
format &= SND_SOC_DAIFMT_FORMAT_MASK;
|
|
format &= SND_SOC_DAIFMT_FORMAT_MASK;
|
|
if (format != SND_SOC_DAIFMT_LEFT_J &&
|
|
if (format != SND_SOC_DAIFMT_LEFT_J &&
|
|
format != SND_SOC_DAIFMT_I2S) {
|
|
format != SND_SOC_DAIFMT_I2S) {
|
|
- dev_err(codec->dev, "Invalid DAI format\n");
|
|
|
|
|
|
+ dev_err(component->dev, "Invalid DAI format\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,8 +102,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params,
|
|
struct snd_pcm_hw_params *params,
|
|
struct snd_soc_dai *dai)
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
{
|
|
- struct snd_soc_codec *codec = dai->codec;
|
|
|
|
- struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
+ struct snd_soc_component *component = dai->component;
|
|
|
|
+ struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
|
|
|
|
|
|
/*
|
|
/*
|
|
* From the datasheet:
|
|
* From the datasheet:
|
|
@@ -123,8 +124,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream,
|
|
static int ak5386_hw_free(struct snd_pcm_substream *substream,
|
|
static int ak5386_hw_free(struct snd_pcm_substream *substream,
|
|
struct snd_soc_dai *dai)
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
{
|
|
- struct snd_soc_codec *codec = dai->codec;
|
|
|
|
- struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
+ struct snd_soc_component *component = dai->component;
|
|
|
|
+ struct ak5386_priv *priv = snd_soc_component_get_drvdata(component);
|
|
|
|
|
|
if (gpio_is_valid(priv->reset_gpio))
|
|
if (gpio_is_valid(priv->reset_gpio))
|
|
gpio_set_value(priv->reset_gpio, 0);
|
|
gpio_set_value(priv->reset_gpio, 0);
|
|
@@ -192,19 +193,12 @@ static int ak5386_probe(struct platform_device *pdev)
|
|
"AK5386 Reset"))
|
|
"AK5386 Reset"))
|
|
priv->reset_gpio = -EINVAL;
|
|
priv->reset_gpio = -EINVAL;
|
|
|
|
|
|
- return snd_soc_register_codec(dev, &soc_codec_ak5386,
|
|
|
|
|
|
+ return devm_snd_soc_register_component(dev, &soc_component_ak5386,
|
|
&ak5386_dai, 1);
|
|
&ak5386_dai, 1);
|
|
}
|
|
}
|
|
|
|
|
|
-static int ak5386_remove(struct platform_device *pdev)
|
|
|
|
-{
|
|
|
|
- snd_soc_unregister_codec(&pdev->dev);
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static struct platform_driver ak5386_driver = {
|
|
static struct platform_driver ak5386_driver = {
|
|
.probe = ak5386_probe,
|
|
.probe = ak5386_probe,
|
|
- .remove = ak5386_remove,
|
|
|
|
.driver = {
|
|
.driver = {
|
|
.name = "ak5386",
|
|
.name = "ak5386",
|
|
.of_match_table = of_match_ptr(ak5386_dt_ids),
|
|
.of_match_table = of_match_ptr(ak5386_dt_ids),
|