All of lore.kernel.org
 help / color / mirror / Atom feed
* What's the deal with elements?
@ 2011-11-23  4:44 Borg Onion
  2011-11-23  8:03 ` Clemens Ladisch
  0 siblings, 1 reply; 4+ messages in thread
From: Borg Onion @ 2011-11-23  4:44 UTC (permalink / raw)
  To: alsa-devel

Hi,

Still writing some basic ALSA software, trying to get to know the API.  I
wrote some software to list cards and their properties, with output like
this:

$ ./list
Card #0: id=ICH6, driver=ICH4, name=Intel ICH6, longname=Intel ICH6 with
AD1981B at irq 17, mixername=Analog Devices AD1981B,
components=AC97a:41445374
Element used = 0, count = 28
Power state = D0
CTL type = Kernel level CTL
Card #1: id=Device, driver=USB-Audio, name=C-Media USB Audio Device,
longname=C-Media USB Audio Device at usb-0000:00:1d.0-1, full speed,
mixername=USB Mixer, components=USB0d8c:0008
Element used = 0, count = 7
Power state = D0
CTL type = Kernel level CTL
No more cards!

Whenever I try to access the elements by their index though, I get errors.
 What's the meaning of "used" vs. "count"?  What are these elements used
for?  I would assume to discover what devices are on a card, but I could be
wrong.  How does one do device discovery?

Thanks,

--BO

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What's the deal with elements?
  2011-11-23  4:44 What's the deal with elements? Borg Onion
@ 2011-11-23  8:03 ` Clemens Ladisch
  2011-11-24  5:52   ` Borg Onion
  0 siblings, 1 reply; 4+ messages in thread
From: Clemens Ladisch @ 2011-11-23  8:03 UTC (permalink / raw)
  To: Borg Onion; +Cc: alsa-devel

Borg Onion wrote:
> Element used = 0, count = 7
> 
> Whenever I try to access the elements by their index though, I get errors.

It's hard to find out what you're talking about without the code, but
this looks as if you've called snd_ctl_elem_list_get_used/count() and
are now wondering why the other snd_ctl_elem_list_get_* functions don't
work.

> What's the meaning of "used" vs. "count"?

The count is the number of elements that the card has.
"used" is the number of elements that you have in the list.

To actually get element IDs, you have to allocate space for them with
snd_ctl_elem_list_alloc_space() (and then don't forget to call
snd_ctl_elem_list_free_space() afterwards), and call snd_ctl_elem_list()
again.  (All this is quite undocumented.)

> What are these elements used for?

Mixer controls.

> How does one do device discovery?

snd_device_name_hint(), or functions like snd_ctl_pcm_next_device().


Regards,
Clemens

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What's the deal with elements?
  2011-11-23  8:03 ` Clemens Ladisch
@ 2011-11-24  5:52   ` Borg Onion
  2011-11-24 13:37     ` Clemens Ladisch
  0 siblings, 1 reply; 4+ messages in thread
From: Borg Onion @ 2011-11-24  5:52 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

>
> > What's the meaning of "used" vs. "count"?
>

> The count is the number of elements that the card has.
> "used" is the number of elements that you have in the list.
>
> To actually get element IDs, you have to allocate space for them with
> snd_ctl_elem_list_alloc_space() (and then don't forget to call
> snd_ctl_elem_list_free_space() afterwards), and call snd_ctl_elem_list()
> again.  (All this is quite undocumented.)
>
>
Wow, I NEVER would have guessed that, and I can truly find no documentation
on the call semantics here, hence my basic questions to this mailing list.

The good news is, your guidance did produce the right results.  But it
sucks you have to probe for devices with *_next_device()...you'd think ALSA
would give you a nice table of devices that are present on the card.  I was
hoping the element list would be that.  Even the "enum _snd_ctl_elem_iface"
definition hints at these element lists containing PCM devices.  Am I
missing something here?

Lastly, my calls to snd_ctl_elem_list_get_index() always return 0.
 Shouldn't they be returning the index passed in?  (I don't really get the
purpose of this function)

The source code for what I've got so far is here:
http://pastebin.com/1pW1MK4f

--BO

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: What's the deal with elements?
  2011-11-24  5:52   ` Borg Onion
@ 2011-11-24 13:37     ` Clemens Ladisch
  0 siblings, 0 replies; 4+ messages in thread
From: Clemens Ladisch @ 2011-11-24 13:37 UTC (permalink / raw)
  To: Borg Onion; +Cc: alsa-devel

Borg Onion wrote:
> the "enum _snd_ctl_elem_iface" definition hints at these element lists
> containing PCM devices.

iface=PCM means that the control is associated with some PCM device
(identified by device/subdevice).

> Lastly, my calls to snd_ctl_elem_list_get_index() always return 0.
> Shouldn't they be returning the index passed in?

A control is identified either by the numid, a non-zero unique number,
or by the interface/device/subdevice/name/index fields.  The index field
is used when there are multiple controls that would otherwise have the
same ID.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-24 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23  4:44 What's the deal with elements? Borg Onion
2011-11-23  8:03 ` Clemens Ladisch
2011-11-24  5:52   ` Borg Onion
2011-11-24 13:37     ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.