[alsa-devel] [PATCH v5 03/12] ALSA: control: Add init callback for kcontrol

Vinod Koul vinod.koul at intel.com
Mon Sep 8 10:08:07 CEST 2014


On Mon, Sep 08, 2014 at 10:04:42AM +0200, Takashi Iwai wrote:
> At Mon, 8 Sep 2014 09:44:21 +0530,
> Vinod Koul wrote:
> > 
> > On Sat, Sep 06, 2014 at 05:56:02PM +0200, Takashi Iwai wrote:
> > > At Sat, 6 Sep 2014 15:21:24 +0100,
> > > Mark Brown wrote:
> > > > 
> > > > On Tue, Sep 02, 2014 at 06:05:58PM +0530, Subhransu S. Prusty wrote:
> > > > > Some controls need to initialize stuffs like pvt data, so they need a
> > > > > callback if the control creation is successful.
> > > > 
> > > > Adding Takashi - this is ALSA core code so he needs to review it.
> > > 
> > > This would bloat effectively the data size of all sound drivers, so I
> > > can't ack it without more proper reasoning.  That is, please convince
> > > me why this change must be taken for the cost of size bloat of all
> > > sound drivers.  Can't you do it in the caller side of snd_ctl_add()
> > > like many other drivers already do?
> > Okay lets step back and see why we need this :)
> > 
> > In our case after the control creation we need to allocate memory which will
> > hold the data for the byte controls. This can be done only after the
> > controls are created (by asoc).
> 
> Why?  Because you don't need how many bytes to allocate?
> 
> > For that we need a callback into driver so that we can allocate the memory.
> > Thats why we added .init() method. If you have any other way to do this, we
> > are all ears :)
> 
> For example, you can embed an init flag into your record and call the
> initializer in get/put callback if not called yet.
Yes but that would involve open coding in all control hanlers for the driver :

if (!initialized)
	allocate_control_mem();

This approach was done earlier (checking in info) and flaged off by Mark. It make better to
have these handled in the framework.

Either ways we are okay with whatever you two decide :)

-- 
~Vinod



More information about the Alsa-devel mailing list