All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
To: "Koskinen Ilkka (Nokia-D/Tampere)" <ilkka.koskinen@nokia.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"tony@atomide.com" <tony@atomide.com>,
	"broonie@opensource.wolfsonmicro.com"
	<broonie@opensource.wolfsonmicro.com>,
	"Valentin Eduardo (Nokia-D/Helsinki)"
	<eduardo.valentin@nokia.com>,
	"Nurkkala Eero.An (EXT-Offcode/Oulu)"
	<ext-Eero.Nurkkala@nokia.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCHv2 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone
Date: Thu, 18 Feb 2010 10:14:36 +0200	[thread overview]
Message-ID: <201002181014.36592.peter.ujfalusi@nokia.com> (raw)
In-Reply-To: <1266417960-22787-3-git-send-email-ilkka.koskinen@nokia.com>

Hello,

Looks good, but I have one comment, you can consider if you like it...

...

> +static int omap_mcbsp2_st_set_mode(struct snd_kcontrol *kcontrol,
> +				struct snd_ctl_elem_value *ucontrol)
> +{
> +	u8 value = ucontrol->value.integer.value[0];
> +
> +	if (value == omap_st_is_enabled(1))
> +		return 0;
> +
> +	if (value)
> +		omap_st_enable(1);
> +	else
> +		omap_st_disable(1);
> +
> +	return 1;
> +}
> +
> +static int omap_mcbsp2_st_get_mode(struct snd_kcontrol *kcontrol,
> +				struct snd_ctl_elem_value *ucontrol)
> +{
> +	ucontrol->value.integer.value[0] = omap_st_is_enabled(1);
> +	return 0;
> +}
> +
> +static int omap_mcbsp3_st_set_mode(struct snd_kcontrol *kcontrol,
> +				struct snd_ctl_elem_value *ucontrol)
> +{
> +	u8 value = ucontrol->value.integer.value[0];
> +
> +	if (value == omap_st_is_enabled(2))
> +		return 0;
> +
> +	if (value)
> +		omap_st_enable(2);
> +	else
> +		omap_st_disable(2);
> +
> +	return 1;
> +}
> +
> +static int omap_mcbsp3_st_get_mode(struct snd_kcontrol *kcontrol,
> +				struct snd_ctl_elem_value *ucontrol)
> +{
> +
> +	ucontrol->value.integer.value[0] = omap_st_is_enabled(2);
> +	return 0;
> +}

Instead of having these two set of function, I would have only one:

static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol,
					struct snd_ctl_elem_value *ucontrol)
{
	struct soc_mixer_control *mc =
			(struct soc_mixer_control *)kcontrol->private_value;
	u8 value = ucontrol->value.integer.value[0];

	if (value == omap_st_is_enabled(mc->reg))
		return 0;

	if (value)
		omap_st_enable(mc->reg);
	else
		omap_st_disable(mc->reg);

	return 1;
}

static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
					struct snd_ctl_elem_value *ucontrol)
{
	struct soc_mixer_control *mc =
			(struct soc_mixer_control *)kcontrol->private_value;

	ucontrol->value.integer.value[0] = omap_st_is_enabled(mc->reg);

	return 0;
}

Than

> +static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
> +	SOC_SINGLE_EXT("McBSP2 Sidetone Switch", 0, 0, 1, 0,
> +			omap_mcbsp2_st_get_mode, omap_mcbsp2_st_set_mode),

	SOC_SINGLE_EXT("McBSP2 Sidetone Switch", 1, 0, 1, 0,
		omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),

> +	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 0 Volume",
> +				      -32768, 32767,
> +				      omap_mcbsp2_get_st_ch0_volume,
> +				      omap_mcbsp2_set_st_ch0_volume),
> +	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
> +				      -32768, 32767,
> +				      omap_mcbsp2_get_st_ch1_volume,
> +				      omap_mcbsp2_set_st_ch1_volume),
> +};
> +
> +static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = {
> +	SOC_SINGLE_EXT("McBSP3 Sidetone Switch", 0, 0, 1, 0,
> +			omap_mcbsp3_st_get_mode, omap_mcbsp3_st_set_mode),

	SOC_SINGLE_EXT("McBSP3 Sidetone Switch", 2, 0, 1, 0,
		omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),

> +	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume",
> +				      -32768, 32767,
> +				      omap_mcbsp3_get_st_ch0_volume,
> +				      omap_mcbsp3_set_st_ch0_volume),
> +	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
> +				      -32768, 32767,
> +				      omap_mcbsp3_get_st_ch1_volume,
> +				      omap_mcbsp3_set_st_ch1_volume),
> +};
> +
> +int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id)
> +{
> +	if (!cpu_is_omap34xx())
> +		return -ENODEV;
> +
> +	switch (mcbsp_id) {
> +	case 2: /* McBSP 2 */
> +		return snd_soc_add_controls(codec, omap_mcbsp2_st_controls,
> +					ARRAY_SIZE(omap_mcbsp2_st_controls));
> +	case 3: /* McBSP 3 */
> +		return snd_soc_add_controls(codec, omap_mcbsp3_st_controls,
> +					ARRAY_SIZE(omap_mcbsp3_st_controls));
> +	default:
> +		break;
> +	}
> +
> +	return -EINVAL;
> +}
> +EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
> +
>  static int __init snd_omap_mcbsp_init(void)
>  {
>  	return snd_soc_register_dais(omap_mcbsp_dai,
> diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h
> index 1968d03..6c363e5 100644
> --- a/sound/soc/omap/omap-mcbsp.h
> +++ b/sound/soc/omap/omap-mcbsp.h
> @@ -57,4 +57,6 @@ enum omap_mcbsp_div {
> 
>  extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS];
> 
> +int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id);
> +
>  #endif

-- 
Péter

  reply	other threads:[~2010-02-18  8:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-17 14:45 [PATCHv2 0/2] McBSP: OMAP3: Add sidetone feature Ilkka Koskinen
2010-02-17 14:45 ` [PATCHv2 1/2] " Ilkka Koskinen
2010-02-17 14:46   ` [PATCHv2 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone Ilkka Koskinen
2010-02-18  8:14     ` Peter Ujfalusi [this message]
2010-02-18  8:49       ` ilkka.koskinen
2010-02-18  0:25   ` [PATCHv2 1/2] McBSP: OMAP3: Add sidetone feature Tony Lindgren
2010-02-18 10:58     ` Ilkka Koskinen
2010-02-18 11:01       ` Mark Brown
2010-02-18 17:16         ` Tony Lindgren
2010-02-18 17:14       ` Tony Lindgren
2010-02-18 13:06 ` [PATCHv2 0/2] " Jarkko Nikula
2010-02-18 14:04   ` Peter Ujfalusi

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=201002181014.36592.peter.ujfalusi@nokia.com \
    --to=peter.ujfalusi@nokia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=eduardo.valentin@nokia.com \
    --cc=ext-Eero.Nurkkala@nokia.com \
    --cc=ilkka.koskinen@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.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.