All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: Petr Kulhavy <petr@barix.com>
Cc: plamen@barix.com, alsa-devel@alsa-project.org,
	broonie@kernel.org, lgirdwood@gmail.com
Subject: Re: [PATCH v2 2/2] ASoC: wm8985: add support for WM8758
Date: Fri, 20 May 2016 17:11:43 +0100	[thread overview]
Message-ID: <20160520161143.GQ1646@localhost.localdomain> (raw)
In-Reply-To: <1463489334-17549-3-git-send-email-petr@barix.com>

On Tue, May 17, 2016 at 02:48:54PM +0200, Petr Kulhavy wrote:
> The WM8758 chip is almost identical to WM8985 with the difference that it
> doesn't feature the AUX input. This patch adds the WM8758 support into the
> WM8985 driver.
> 
> The chip selection is done by the I2C name. The SPI probe supports only
> the WM8985.
> 
> Signed-off-by: Petr Kulhavy <petr@barix.com>
> ---
> +
> +static int wm8985_add_widgets(struct snd_soc_codec *codec)
> +{
> +	struct wm8985_priv *wm8985 = snd_soc_codec_get_drvdata(codec);
> +	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
> +
> +	snd_soc_dapm_new_controls(dapm, wm8985_common_dapm_widgets,
> +		ARRAY_SIZE(wm8985_common_dapm_widgets));
> +	snd_soc_dapm_add_routes(dapm, wm8985_common_dapm_routes,
> +		ARRAY_SIZE(wm8985_common_dapm_routes));
> +
> +	switch (wm8985->dev_type) {
> +	case WM8758:
> +		snd_soc_add_codec_controls(codec, wm8985_alc_snd_controls,
> +			ARRAY_SIZE(wm8985_alc_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_adc_snd_controls,
> +			ARRAY_SIZE(wm8985_adc_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_dac_snd_controls,
> +			ARRAY_SIZE(wm8985_dac_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_eq_snd_controls,
> +			ARRAY_SIZE(wm8985_eq_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_3d_snd_controls,
> +			ARRAY_SIZE(wm8985_3d_snd_controls));

Why not just put all these in a common controls array? They seem
to all be used on 8985 as well.

> +
> +		snd_soc_dapm_new_controls(dapm, wm8758_dapm_widgets,
> +					  ARRAY_SIZE(wm8758_dapm_widgets));
> +		break;
> +
> +	case WM8985:
> +		snd_soc_add_codec_controls(codec, wm8985_alc_snd_controls,
> +			ARRAY_SIZE(wm8985_alc_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_adc_snd_controls,
> +			ARRAY_SIZE(wm8985_adc_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_dac_snd_controls,
> +			ARRAY_SIZE(wm8985_dac_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_aux_snd_controls,
> +			ARRAY_SIZE(wm8985_aux_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_eq_snd_controls,
> +			ARRAY_SIZE(wm8985_eq_snd_controls));
> +		snd_soc_add_codec_controls(codec, wm8985_3d_snd_controls,
> +			ARRAY_SIZE(wm8985_3d_snd_controls));

> +		snd_soc_add_codec_controls(codec, wm8985_spkr_snd_controls,
> +			ARRAY_SIZE(wm8985_spkr_snd_controls));

And why not put aux and spkr in a wm8985 array? Then you only
need two arrays.

> +
> +		snd_soc_dapm_new_controls(dapm, wm8985_dapm_widgets,
> +			ARRAY_SIZE(wm8985_dapm_widgets));
> +		snd_soc_dapm_add_routes(dapm, wm8985_aux_dapm_routes,
> +			ARRAY_SIZE(wm8985_aux_dapm_routes));
> +		break;
> +	}
> +
> +	return 0;
> +}
>  
>  static int eqmode_get(struct snd_kcontrol *kcontrol,
>  		      struct snd_ctl_elem_value *ucontrol)
> @@ -1005,6 +1120,8 @@ static int wm8985_probe(struct snd_soc_codec *codec)
>  	snd_soc_update_bits(codec, WM8985_BIAS_CTRL, WM8985_BIASCUT,
>  			    WM8985_BIASCUT);
>  
> +	wm8985_add_widgets(codec);
> +
>  	return 0;
>  
>  err_reg_enable:
> @@ -1047,13 +1164,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8985 = {
>  	.probe = wm8985_probe,
>  	.set_bias_level = wm8985_set_bias_level,
>  	.suspend_bias_off = true,
> -
> -	.controls = wm8985_snd_controls,
> -	.num_controls = ARRAY_SIZE(wm8985_snd_controls),
> -	.dapm_widgets = wm8985_dapm_widgets,
> -	.num_dapm_widgets = ARRAY_SIZE(wm8985_dapm_widgets),
> -	.dapm_routes = wm8985_dapm_routes,
> -	.num_dapm_routes = ARRAY_SIZE(wm8985_dapm_routes),

I think you should still be able to use these for the common
functionality.

Thanks,
Charles

  reply	other threads:[~2016-05-20 16:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 12:48 [PATCH v2 0/2] ASoC: wm8985: add support for WM8758 Petr Kulhavy
2016-05-17 12:48 ` [PATCH v2 1/2] ASoC: wm8985: add register definitions " Petr Kulhavy
2016-05-20 15:54   ` Charles Keepax
2016-05-17 12:48 ` [PATCH v2 2/2] ASoC: wm8985: add support " Petr Kulhavy
2016-05-20 16:11   ` Charles Keepax [this message]
2016-05-23  7:34     ` Petr Kulhavy
2016-05-23  7:53       ` Charles Keepax
2016-05-23  8:17         ` Petr Kulhavy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160520161143.GQ1646@localhost.localdomain \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=petr@barix.com \
    --cc=plamen@barix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.