1.kernel 部分control控制codec寄存器流程
module_platform_driver(msm8x16_asoc_machine_driver)-------------------------kernel/sound/soc/msm/msm8x16.c
->msm8x16_asoc_machine_probe
->snd_soc_register_card(card)
->snd_soc_instantiate_card(card)
->snd_card_create()
->snd_ctl_create(card)
->snd_ctl_dev_register()
->snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1,&snd_ctl_f_ops, card, name)--------------------------kernel/sound/core/control.c
->snd_ctl_ioctl()
->snd_ctl_elem_info_user(ctl, argp)
->snd_ctl_elem_read_user(card, argp)
->snd_ctl_elem_write_user(ctl, argp)
->snd_ctl_elem_write(card, file, control)
->snd_ctl_find_id(card, &control->id)
->kctl->put(kctl, control)
snd_kcontrol_newmsm_snd_controls[]---------------------------------------kernel/sound/soc/msm/msm8x16.c
->snd_soc_add_codec_controls(codec,msm_snd_controls,ARRAY_SIZE(msm_snd_controls))
->snd_soc_add_controls()
->snd_ctl_add()
->list_add_tail(&kcontrol->list, &card->controls)
2.hal层调用音频通路配置文件mixer_paths_mtp.xml初始化流程
qcom/audio/hal/msm8916/platform.c:40:#defineMIXER_XML_PATH_MTP "/system/etc/mixer_paths_mtp.xml"
static void query_platform(const char *snd_card_name,
528 char*mixer_xml_path)
529 {
530 if (!strncmp(snd_card_name, "msm8x16-snd-card-mtp",
531 sizeof("msm8x16-snd-card-mtp"))) {
532 strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP,
533 sizeof(MIXER_XML_PATH_MTP));
………
999 }
adev->audio_route= audio_route_init(snd_card_num,mixer_xml_path);
system/media/audio_route/include/audio_route/audio_route.h:25:structaudio_route *audio_route_init(unsigned int card, const char *xml_path);
system/media/audio_route/audio_route.c:721:structaudio_route *audio_route_init(unsignedint card, const char *xml_path)
3.hal层设备调用底层流程
start_output_stream(structstream_out *out)
->select_devices(adev,out->usecase)
->enable_snd_device(adev,out_snd_device)
->audio_route_apply_and_update_path(adev->audio_route,device_name)
->audio_route_update_path(ar,name, false /*reverse*/)
->mixer_ctl_set_value(ms->ctl, 0, ms->new_value[0])
->mixer_ctl_set_array(ms->ctl, ms->new_value, ms->num_values)
->ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev)