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

Ilkka Koskinen ikoskine at nokia.com
Fri Feb 19 13:04:38 CET 2010



On Fri, 19 Feb 2010, Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:

>
>> +
>> +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 ;)

I'm a bit confused. What do you mean by that?

AFAICS, Q1.14 defines values [-16384.0, +16383.5], which are mapped in the 
driver to integers [-32768, 32767], right? Moreover, those Q1.14 values in 
registers are mapped to [-2, 2] in HW. So is there a problem somewhere?

Cheers, Ilkka


More information about the Alsa-devel mailing list