网上对amixer工具的使用较多,但使用kcontrol coding的例子有限,目前比较好的一篇文章如下:
http://blog.chinaunix.net/uid-27875-id-5783294.html
amixer指令:
显示:amixer -c 0 controls
读:amixer -c 0 cget iface=MIXER,name='ADC2L Source PIN Select'
写:amixer -c 0 cset iface=MIXER,name='ADC2L Source PIN Select' 1
以下是基于此参考demo完成的自定义kcontrol的demo code:
const char *str_L = "iface=MIXER,name='ADC2L Source PIN Select'";
char L_PIN = '0';
snd_ctl_t *handle = NULL;
snd_ctl_elem_id_t *id;
snd_ctl_elem_info_t *info;
snd_ctl_elem_value_t *control;
snd_ctl_open(&handle, "hw:0", 0)
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_info_alloca(&info);
snd_ctl_elem_value_alloca(&control);
snd_ctl_ascii_elem_id_parse(id, str_L);
snd_ctl_elem_info_set_id(info, id);
snd_ctl_elem_info(handle, info)
snd_ctl_elem_info_get_id(info, id);
snd_ctl_elem_value_set_id(control, id);
snd_ctl_elem_read(handle, control)
snd_ctl_ascii_value_parse(handle, control, info, &L_PIN);
snd_ctl_elem_write(handle, control)
snd_ctl_close(handle);