[alsa-devel] [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

ext-Eero.Nurkkala at nokia.com ext-Eero.Nurkkala at nokia.com
Fri Feb 19 08:30:30 CET 2010


> +
> +static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
> +       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", 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),
> +};
> +

Just a short note,
"Gain values are in the interval (-2..2) in Q1.14 format, negative values are expressed in
2's complement."

So, from:
http://en.wikipedia.org/wiki/Q_(number_format)

"
The notation used is Qm.n, where:

    * Q designates that the number is in Q format notation — the Texas Instruments representation for signed fixed-point numbers.
    * m (optional; default=0) is the number of bits used to designate the two's complement integer portion of the number, exclusive of the sign bit.
    * n is the number of bits used to designate the two's complement fractional portion of the number, i.e. the number of bits to the right of the binary point.
"

..so if you do tests, and find out the gains behave "irrationally" occasionally, you can't possibly claim it isn't working as expected ;)

- Eero


More information about the Alsa-devel mailing list