[alsa-devel] Query regarding ALSA control interface
Hi I am writing a pcm control interface for my alsa driver. I am confused about how the switches are used. I have implemented simple cases like following and they are working well.
static int audio_path_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { /*Count is 256 since the values can vary from 0-255. But values fall in this range only*/
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 256; uinfo->value.integer.min = 0; uinfo->value.integer.max = 255; FN_EXIT; return 0; } static int audio_path_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { my_mixer_t *mixer_chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = mixer_chip->echo; ucontrol->value.integer.value[1] = mixer_chip->echo; return 0; } static int audio_path_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { my_mixer_t *mixer_chip = snd_kcontrol_chip(kcontrol); ----- ---- }
Now, I have to implement a control which takes four different values..namely 0,1.100 and 101. In this case what shoud be the type of control? It should be ENUMERATED or INTEGER? I am confused here since the values are not exactly in a range.
-pharaoh.
Pharaoh . wrote:
Now, I have to implement a control which takes four different values..namely 0,1.100 and 101. In this case what shoud be the type of control? It should be ENUMERATED or INTEGER? I am confused here since the values are not exactly in a range.
An INTEGER control takes numeric values in a specific range, while an ENUMERATED control takes values that are not numerically related (but that are _internally_ represented as integers in a specific range).
In your case, you'd probably want to use an enumerated control with the range 0..3, which maps to the four names "0", "1", "100" and "101".
HTH Clemens
On 7/24/07, Clemens Ladisch cladisch@fastmail.net wrote:
Pharaoh . wrote:
Now, I have to implement a control which takes four different
values..namely
0,1.100 and 101. In this case what shoud be the type of control? It
should
be ENUMERATED or INTEGER? I am confused here since the values are not exactly in a range.
An INTEGER control takes numeric values in a specific range, while an ENUMERATED control takes values that are not numerically related (but that are _internally_ represented as integers in a specific range).
In your case, you'd probably want to use an enumerated control with the range 0..3, which maps to the four names "0", "1", "100" and "101".
HTH Clemens
Thanks Clemens, I had implemented it using ENUM type. It works.
-pharaoh.
participants (2)
-
Clemens Ladisch
-
Pharaoh .