[alsa-devel] [PATCH v9 1/6] ASoC: Intel: mrfld: add the gain controls

Vinod Koul vinod.koul at intel.com
Wed Oct 15 12:23:03 CEST 2014


On Wed, Oct 15, 2014 at 12:49:47PM +0200, Mark Brown wrote:
> On Wed, Oct 15, 2014 at 12:34:56PM +0530, Vinod Koul wrote:
> 
> > +static const struct snd_kcontrol_new sst_gain_controls[] = {
> > +	SST_GAIN("media0_in", SST_PATH_INDEX_MEDIA0_IN, SST_TASK_MMX, 0, &sst_gains[0]),
> > +	SST_GAIN("media1_in", SST_PATH_INDEX_MEDIA1_IN, SST_TASK_MMX, 0, &sst_gains[1]),
> 
> > +
> > +/* the SST_GAIN macro above will create three alsa controls for each
> > + * instance invoked, gain, mute and ramp duration, which use the same gain
> > + * cell sst_gain to keep track of data
> > + *
> > + * To calculate number of gain cell instances we need to device by 3 in
> > + * below caulcation for gain cell memory.
> > + * This gets rid of static number and issues while adding new controls
> > + */
> > +static struct sst_gain_value sst_gains[ARRAY_SIZE(sst_gain_controls)/3];
> 
> The use of ARRAY_SIZE() is nice here but I'm a bit confused about the
> divide by 3 - there's an entry in sst_gains referenced for each element
> in sst_gain_controls.
Thats is the reason added the comment above.

gain cells are used to represent the three ALSA controls. So SST_GAIN macro
expands expands to three kcontrols. If we have 5 names in array, then
ARRAY_SIZE once expanded will tell me 15.

But for gain cell allocation, we use single gain cell in firmware to
represent all three controls, so that is why we divide here by three when
allocation the gain cells. Here in example we need only 5 cells. So SST_GAIN
macro has to be compensated for by dividing by 3 :)

Thanks

-- 
~Vinod
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20141015/d3d5e285/attachment.sig>


More information about the Alsa-devel mailing list