Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 12132de6 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

ASoC: ak5386: replace codec to component



Now we can replace Codec to Component. Let's do it.

Note:
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 0	->	.idle_bias_on = 1
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
Loading
Loading
Loading
Loading
+28 −34
Original line number Diff line number Diff line
@@ -38,30 +38,29 @@ static const struct snd_soc_dapm_route ak5386_dapm_routes[] = {
	{ "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);
}

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);
	return 0;
}

#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);
	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);
}
#else
@@ -69,28 +68,30 @@ static int ak5386_soc_resume(struct snd_soc_codec *codec)
#define ak5386_soc_resume	NULL
#endif /* CONFIG_PM */

static const struct snd_soc_codec_driver soc_codec_ak5386 = {
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,
	.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),
	},
	.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,
			      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;
	if (format != SND_SOC_DAIFMT_LEFT_J &&
	    format != SND_SOC_DAIFMT_I2S) {
		dev_err(codec->dev, "Invalid DAI format\n");
		dev_err(component->dev, "Invalid DAI format\n");
		return -EINVAL;
	}

@@ -101,8 +102,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *params,
			    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:
@@ -123,8 +124,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream,
static int ak5386_hw_free(struct snd_pcm_substream *substream,
			  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))
		gpio_set_value(priv->reset_gpio, 0);
@@ -192,19 +193,12 @@ static int ak5386_probe(struct platform_device *pdev)
					  "AK5386 Reset"))
			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);
}

static int ak5386_remove(struct platform_device *pdev)
{
	snd_soc_unregister_codec(&pdev->dev);
	return 0;
}

static struct platform_driver ak5386_driver = {
	.probe		= ak5386_probe,
	.remove		= ak5386_remove,
	.driver		= {
		.name	= "ak5386",
		.of_match_table = of_match_ptr(ak5386_dt_ids),