From 7a4fcedce878e2a05a3028f72c014f088dd245fd Mon Sep 17 00:00:00 2001 From: Binyuan Lan Date: Tue, 6 Mar 2018 10:22:30 +0800 Subject: [PATCH] ASoC: rockchip: rk817-codec: dynamically enable/disable mclk Change-Id: I57c97c72ff294bcf63590aa79c6ce0656dc8b022 Signed-off-by: Binyuan Lan --- sound/soc/codecs/rk817_codec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rk817_codec.c b/sound/soc/codecs/rk817_codec.c index 51514ca4819f..bd3d6be08cf9 100644 --- a/sound/soc/codecs/rk817_codec.c +++ b/sound/soc/codecs/rk817_codec.c @@ -451,6 +451,11 @@ static int rk817_playback_path_put(struct snd_kcontrol *kcontrol, DBG("%s : set playback_path %ld, pre_path %ld\n", __func__, rk817->playback_path, pre_path); + if (rk817->playback_path != OFF) + clk_prepare_enable(rk817->mclk); + else + clk_disable_unprepare(rk817->mclk); + switch (rk817->playback_path) { case OFF: if (pre_path != OFF && (pre_path != HP_PATH && @@ -565,6 +570,11 @@ static int rk817_capture_path_put(struct snd_kcontrol *kcontrol, DBG("%s : set capture_path %ld, pre_path %ld\n", __func__, rk817->capture_path, pre_path); + if (rk817->capture_path != MIC_OFF) + clk_prepare_enable(rk817->mclk); + else + clk_disable_unprepare(rk817->mclk); + switch (rk817->capture_path) { case MIC_OFF: if (pre_path != MIC_OFF) @@ -919,7 +929,6 @@ static int rk817_platform_probe(struct platform_device *pdev) ret = -ENXIO; goto err_; } - clk_prepare_enable(rk817_codec_data->mclk); ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_rk817, rk817_dai, ARRAY_SIZE(rk817_dai)); @@ -937,11 +946,6 @@ err_: static int rk817_platform_remove(struct platform_device *pdev) { - struct rk817_codec_priv *rk817 = dev_get_drvdata(&pdev->dev); - - if (!IS_ERR(rk817->mclk)) - clk_disable_unprepare(rk817->mclk); - snd_soc_unregister_codec(&pdev->dev); return 0;