[alsa-devel] [PATCH] ASoC: wm8994: codec driver should manage its own MCLK

Nicolin Chen nicoleotsuka at gmail.com
Thu Mar 3 19:14:53 CET 2016


On Thu, Mar 03, 2016 at 02:45:35PM +0800, Zidan Wang wrote:
> codec driver should manage its own master clock, MCLK1 and MCLK2.
> When bias_level change from standby to prepare, enable codec MCLK.
> When bias_level change from prepare to standby, disable codec MCLK.

Not sure the desired sequence here, would be neater to use runtime pm?

> @@ -270,6 +271,7 @@ static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
>  {
>  	struct device_node *np = wm8994->dev->of_node;
>  	struct wm8994_pdata *pdata = &wm8994->pdata;
> +	char tmp[8];
>  	int i;
>  
>  	if (!np)
> @@ -310,6 +312,11 @@ static int wm8994_set_pdata_from_of(struct wm8994 *wm8994)
>  	if (pdata->ldo[1].enable < 0)
>  		pdata->ldo[1].enable = 0;
>  
> +	for (i = 0; i < WM8994_NUM_MCLK; i++) {
> +		sprintf(tmp, "MCLK%d", i + 1);
> +		pdata->mclk[i] = devm_clk_get(wm8994->dev, tmp);

Probe defer?

> @@ -2474,6 +2475,8 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
>  {
>  	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
>  	struct wm8994 *control = wm8994->wm8994;
> +	struct wm8994_pdata *pdata = &control->pdata;
> +	int i;
>  
>  	wm_hubs_set_bias_level(codec, level);
>  
> @@ -2495,8 +2498,13 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
>  			break;
>  		}
>  
> -		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY)
> +		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) {
>  			active_reference(codec);
> +
> +			for (i = 0; i < WM8994_NUM_MCLK; i++)
> +				if (!IS_ERR(pdata->mclk[i]))
> +					clk_prepare_enable(pdata->mclk[i]);

Return value? You probably should refer to wm8962 or wm8960.


More information about the Alsa-devel mailing list