From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: snd_kcontrol_new_t Date: Fri, 16 May 2003 11:28:00 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20030515195544.22379.h003.c012.wm@mail.icqmail.com.criticalpath.net> Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20030515195544.22379.h003.c012.wm@mail.icqmail.com.criticalpath.net> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Eliot Blennerhassett Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Thu, 15 May 2003 19:55:44 -0700 (PDT), Eliot Blennerhassett wrote: > > typedef struct _snd_kcontrol_new { > snd_ctl_elem_iface_t iface; /* interface identifier */ > unsigned int device; /* device/client number */ > unsigned int subdevice; /* subdevice (substream) number */ > unsigned char *name; /* ASCII name of item */ > unsigned int index; /* index of item */ > unsigned int access; /* access rights */ > unsigned int count; /* count of same elements */ > snd_kcontrol_info_t *info; > snd_kcontrol_get_t *get; > snd_kcontrol_put_t *put; > unsigned long private_value; > } snd_kcontrol_new_t; > > I'd like some explanation (or pointer to where I can read about) the meaning/use > of some fields. (The comments say what they are, but not what they are FOR). > > What is the effect of setting the device,subdevice or index number when creating > a control? It seems that I can leave them set to 0 as long as the name is > unique. yes. the device and subdevice are used to specify the corresponding device. they are for pcm or other interfaces. in the case of mixer, they are only zero because there is only one mixer (although you are allowed to set them). the index is used for multiple controls with the same name, e.g. multiple ac97 codecs. this field is used also for accessing the matrix-type control. you need to convert multi-dimension to a linear address by yourself, though. > (as I mentioned in another post) I get trouble if I try to create two controls > with the same name and different indices (by two calls to snd_ctl_add) > Perhaps the only legal way to do this is to set count > 1 and create a set of > controls with one call to snd_ctl_add()? no, calling snd_ctl_add() twice is ok. (in fact, snd_ctl_add() even doesn't check the double entries :) the counts > 1 is used when there are really identical controls with different indices. that means, the same callback is used with the same private_data and private_value closures but with a different index. so it's suitable for a matrix-mixer style control, or controls bundled with the (multi-channel/play) pcm streams. Takashi ------------------------------------------------------- Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara The only event dedicated to issues related to Linux enterprise solutions www.enterpriselinuxforum.com