Lines Matching refs:aio
160 static void init_device_settings(struct alsa_io *aio);
253 struct alsa_io *aio = (struct alsa_io *)iodev; in set_hwparams() local
258 if (aio->hwparams_set) in set_hwparams()
266 rc = cras_alsa_set_hwparams(aio->handle, iodev->format, in set_hwparams()
268 aio->dma_period_set_microsecs); in set_hwparams()
272 aio->hwparams_set = 1; in set_hwparams()
283 struct alsa_io *aio = (struct alsa_io *)iodev; in frames_queued() local
287 rc = cras_alsa_get_avail_frames(aio->handle, in frames_queued()
288 aio->base.buffer_size, in frames_queued()
289 aio->severe_underrun_frames, in frames_queued()
294 aio->num_severe_underruns++; in frames_queued()
297 if (!aio->enable_htimestamp) in frames_queued()
308 struct alsa_io *aio = (struct alsa_io *)iodev; in delay_frames() local
312 rc = cras_alsa_get_delay_frames(aio->handle, in delay_frames()
323 struct alsa_io *aio = (struct alsa_io *)iodev; in close_dev() local
326 if (aio->poll_fd >= 0) in close_dev()
329 aio->poll_fd); in close_dev()
330 if (!aio->handle) in close_dev()
332 cras_alsa_pcm_close(aio->handle); in close_dev()
333 aio->handle = NULL; in close_dev()
334 aio->is_free_running = 0; in close_dev()
335 aio->filled_zeros_for_draining = 0; in close_dev()
336 aio->hwparams_set = 0; in close_dev()
337 cras_iodev_free_format(&aio->base); in close_dev()
338 cras_iodev_free_audio_area(&aio->base); in close_dev()
345 struct alsa_io *aio = (struct alsa_io *)arg; in dummy_hotword_cb() local
346 audio_thread_rm_callback(aio->poll_fd); in dummy_hotword_cb()
347 aio->poll_fd = -1; in dummy_hotword_cb()
348 aio->base.input_streaming = 1; in dummy_hotword_cb()
358 struct alsa_io *aio = (struct alsa_io *)iodev; in open_dev() local
362 rc = cras_alsa_pcm_open(&handle, aio->dev, aio->alsa_stream); in open_dev()
366 aio->handle = handle; in open_dev()
373 struct alsa_io *aio = (struct alsa_io *)iodev; in configure_dev() local
381 aio->num_underruns = 0; in configure_dev()
382 aio->is_free_running = 0; in configure_dev()
383 aio->filled_zeros_for_draining = 0; in configure_dev()
384 aio->severe_underrun_frames = in configure_dev()
390 aio->dev, iodev->format->frame_rate, in configure_dev()
398 rc = cras_alsa_set_channel_map(aio->handle, in configure_dev()
404 rc = cras_alsa_set_swparams(aio->handle, &aio->enable_htimestamp); in configure_dev()
409 init_device_settings(aio); in configure_dev()
411 aio->poll_fd = -1; in configure_dev()
416 count = snd_pcm_poll_descriptors_count(aio->handle); in configure_dev()
426 rc = snd_pcm_poll_descriptors(aio->handle, ufds, count); in configure_dev()
437 aio->poll_fd = ufds[i].fd; in configure_dev()
443 if (aio->poll_fd >= 0) in configure_dev()
444 audio_thread_add_callback(aio->poll_fd, in configure_dev()
446 aio); in configure_dev()
450 if (aio->alsa_stream == SND_PCM_STREAM_CAPTURE) in configure_dev()
451 cras_alsa_pcm_start(aio->handle); in configure_dev()
465 static int has_handle(const struct alsa_io *aio) in has_handle() argument
467 return !!aio->handle; in has_handle()
472 struct alsa_io *aio = (struct alsa_io *)iodev; in start() local
473 snd_pcm_t *handle = aio->handle; in start()
501 struct alsa_io *aio = (struct alsa_io *)iodev; in get_buffer() local
507 aio->mmap_offset = 0; in get_buffer()
510 rc = cras_alsa_mmap_begin(aio->handle, in get_buffer()
513 &aio->mmap_offset, in get_buffer()
527 struct alsa_io *aio = (struct alsa_io *)iodev; in put_buffer() local
529 return cras_alsa_mmap_commit(aio->handle, in put_buffer()
530 aio->mmap_offset, in put_buffer()
536 struct alsa_io *aio = (struct alsa_io *)iodev; in flush_buffer() local
540 nframes = snd_pcm_avail(aio->handle); in flush_buffer()
541 nframes = snd_pcm_forwardable(aio->handle); in flush_buffer()
542 return snd_pcm_forward(aio->handle, nframes); in flush_buffer()
584 struct alsa_io *aio = (struct alsa_io *)iodev; in update_channel_layout() local
589 if (aio->ucm && (iodev->direction == CRAS_STREAM_INPUT)) { in update_channel_layout()
605 return cras_alsa_get_channel_map(aio->handle, iodev->format); in update_channel_layout()
610 struct alsa_io *aio = (struct alsa_io *)iodev; in set_hotword_model() local
611 if (!aio->ucm) in set_hotword_model()
614 return ucm_set_hotword_model(aio->ucm, model_name); in set_hotword_model()
619 struct alsa_io *aio = (struct alsa_io *)iodev; in get_hotword_models() local
620 if (!aio->ucm) in get_hotword_models()
623 return ucm_get_hotword_models(aio->ucm); in get_hotword_models()
630 static struct alsa_output_node *get_active_output(const struct alsa_io *aio) in get_active_output() argument
632 return (struct alsa_output_node *)aio->base.active_node; in get_active_output()
635 static struct alsa_input_node *get_active_input(const struct alsa_io *aio) in get_active_input() argument
637 return (struct alsa_input_node *)aio->base.active_node; in get_active_input()
645 const struct alsa_io *aio, in get_curve_for_output_node() argument
650 return aio->default_volume_curve; in get_curve_for_output_node()
657 const struct alsa_io *aio) in get_curve_for_active_output() argument
659 struct alsa_output_node *node = get_active_output(aio); in get_curve_for_active_output()
660 return get_curve_for_output_node(aio, node); in get_curve_for_active_output()
666 static void set_alsa_volume_limits(struct alsa_io *aio) in set_alsa_volume_limits() argument
671 if (!has_handle(aio)) in set_alsa_volume_limits()
674 curve = get_curve_for_active_output(aio); in set_alsa_volume_limits()
683 static void set_alsa_mute_control(const struct alsa_io *aio, int muted) in set_alsa_mute_control() argument
687 if (!has_handle(aio)) in set_alsa_mute_control()
690 aout = get_active_output(aio); in set_alsa_mute_control()
692 aio->mixer, in set_alsa_mute_control()
704 const struct alsa_io *aio = (const struct alsa_io *)iodev; in set_alsa_volume() local
709 assert(aio); in set_alsa_volume()
710 if (aio->mixer == NULL) in set_alsa_volume()
714 if (!has_handle(aio)) in set_alsa_volume()
718 curve = get_curve_for_active_output(aio); in set_alsa_volume()
721 aout = get_active_output(aio); in set_alsa_volume()
731 aio->mixer, in set_alsa_volume()
739 const struct alsa_io *aio = (const struct alsa_io *)iodev; in set_alsa_mute() local
740 set_alsa_mute_control(aio, cras_system_get_mute()); in set_alsa_mute()
750 const struct alsa_io *aio = (const struct alsa_io *)iodev; in set_alsa_capture_gain() local
754 assert(aio); in set_alsa_capture_gain()
755 if (aio->mixer == NULL) in set_alsa_capture_gain()
759 if (!has_handle(aio)) in set_alsa_capture_gain()
768 ain = get_active_input(aio); in set_alsa_capture_gain()
771 aio->mixer, in set_alsa_capture_gain()
774 cras_alsa_mixer_set_capture_mute(aio->mixer, in set_alsa_capture_gain()
785 const struct alsa_io *aio = (const struct alsa_io *)iodev; in set_alsa_node_swapped() local
786 assert(aio); in set_alsa_node_swapped()
787 return ucm_enable_swap_mode(aio->ucm, node->name, enable); in set_alsa_node_swapped()
795 static void init_device_settings(struct alsa_io *aio) in init_device_settings() argument
799 if (aio->base.direction == CRAS_STREAM_OUTPUT) { in init_device_settings()
800 set_alsa_volume_limits(aio); in init_device_settings()
801 set_alsa_volume(&aio->base); in init_device_settings()
802 set_alsa_mute(&aio->base); in init_device_settings()
805 struct alsa_input_node *ain = get_active_input(aio); in init_device_settings()
811 if (cras_iodev_software_volume_needed(&aio->base)) { in init_device_settings()
813 &aio->base); in init_device_settings()
815 &aio->base); in init_device_settings()
819 aio->mixer, mixer_input); in init_device_settings()
822 aio->mixer, mixer_input); in init_device_settings()
826 set_alsa_capture_gain(&aio->base); in init_device_settings()
839 static void free_alsa_iodev_resources(struct alsa_io *aio) in free_alsa_iodev_resources() argument
844 free(aio->base.supported_rates); in free_alsa_iodev_resources()
845 free(aio->base.supported_channel_counts); in free_alsa_iodev_resources()
846 free(aio->base.supported_formats); in free_alsa_iodev_resources()
848 DL_FOREACH(aio->base.nodes, node) { in free_alsa_iodev_resources()
849 if (aio->base.direction == CRAS_STREAM_OUTPUT) { in free_alsa_iodev_resources()
853 cras_iodev_rm_node(&aio->base, node); in free_alsa_iodev_resources()
858 free((void *)aio->dsp_name_default); in free_alsa_iodev_resources()
859 cras_iodev_free_resources(&aio->base); in free_alsa_iodev_resources()
860 free(aio->dev); in free_alsa_iodev_resources()
861 if (aio->dev_id) in free_alsa_iodev_resources()
862 free(aio->dev_id); in free_alsa_iodev_resources()
863 if (aio->dev_name) in free_alsa_iodev_resources()
864 free(aio->dev_name); in free_alsa_iodev_resources()
870 static int first_internal_device(struct alsa_io *aio) in first_internal_device() argument
872 return aio->is_first && aio->card_type == ALSA_CARD_TYPE_INTERNAL; in first_internal_device()
878 static int has_node(struct alsa_io *aio, const char *name) in has_node() argument
882 DL_FOREACH(aio->base.nodes, node) in has_node()
984 static int get_ucm_flag_integer(struct alsa_io *aio, in get_ucm_flag_integer() argument
991 if (!aio->ucm) in get_ucm_flag_integer()
994 value = ucm_get_flag(aio->ucm, flag_name); in get_ucm_flag_integer()
1004 static int auto_unplug_input_node(struct alsa_io *aio) in auto_unplug_input_node() argument
1007 if (get_ucm_flag_integer(aio, "AutoUnplugInputNode", &result)) in auto_unplug_input_node()
1012 static int auto_unplug_output_node(struct alsa_io *aio) in auto_unplug_output_node() argument
1015 if (get_ucm_flag_integer(aio, "AutoUnplugOutputNode", &result)) in auto_unplug_output_node()
1020 static int no_create_default_input_node(struct alsa_io *aio) in no_create_default_input_node() argument
1023 if (get_ucm_flag_integer(aio, "NoCreateDefaultInputNode", &result)) in no_create_default_input_node()
1028 static int no_create_default_output_node(struct alsa_io *aio) in no_create_default_output_node() argument
1031 if (get_ucm_flag_integer(aio, "NoCreateDefaultOutputNode", &result)) in no_create_default_output_node()
1037 struct alsa_output_node *output, struct alsa_io *aio) in set_output_node_software_volume_needed() argument
1040 struct cras_alsa_mixer *mixer = aio->mixer; in set_output_node_software_volume_needed()
1043 if (aio->ucm && ucm_get_disable_software_volume(aio->ucm)) { in set_output_node_software_volume_needed()
1072 struct alsa_input_node *input, struct alsa_io *aio) in set_input_node_software_volume_needed() argument
1083 if (!aio->ucm) in set_input_node_software_volume_needed()
1086 rc = ucm_get_max_software_gain(aio->ucm, input->base.name, in set_input_node_software_volume_needed()
1100 rc = ucm_get_min_software_gain(aio->ucm, input->base.name, in set_input_node_software_volume_needed()
1119 struct alsa_io *aio) in set_input_default_node_gain() argument
1124 if (!aio->ucm) in set_input_default_node_gain()
1127 rc = ucm_get_default_node_gain(aio->ucm, input->base.name, in set_input_default_node_gain()
1135 static void check_auto_unplug_output_node(struct alsa_io *aio, in check_auto_unplug_output_node() argument
1141 if (!auto_unplug_output_node(aio)) in check_auto_unplug_output_node()
1146 DL_FOREACH(aio->base.nodes, tmp) in check_auto_unplug_output_node()
1152 DL_FOREACH(aio->base.nodes, tmp) { in check_auto_unplug_output_node()
1166 static struct alsa_output_node *new_output(struct alsa_io *aio, in new_output() argument
1172 if (aio == NULL) { in new_output()
1181 output->base.dev = &aio->base; in new_output()
1182 output->base.idx = aio->next_ionode_index++; in new_output()
1185 aio->base.info.stable_id); in new_output()
1188 aio->base.info.stable_id_new in new_output()
1194 aio->config, in new_output()
1199 set_node_initial_state(&output->base, aio->card_type); in new_output()
1200 set_output_node_software_volume_needed(output, aio); in new_output()
1202 cras_iodev_add_node(&aio->base, &output->base); in new_output()
1204 check_auto_unplug_output_node(aio, &output->base, output->base.plugged); in new_output()
1211 struct alsa_io *aio = (struct alsa_io *)callback_arg; in new_output_by_mixer_control() local
1219 if (aio->card_type == ALSA_CARD_TYPE_USB) { in new_output_by_mixer_control()
1221 aio->base.info.name, ctl_name) > 0) { in new_output_by_mixer_control()
1222 new_output(aio, cras_output, node_name); in new_output_by_mixer_control()
1225 new_output(aio, cras_output, ctl_name); in new_output_by_mixer_control()
1229 static void check_auto_unplug_input_node(struct alsa_io *aio, in check_auto_unplug_input_node() argument
1234 if (!auto_unplug_input_node(aio)) in check_auto_unplug_input_node()
1240 DL_FOREACH(aio->base.nodes, tmp) in check_auto_unplug_input_node()
1246 DL_FOREACH(aio->base.nodes, tmp) in check_auto_unplug_input_node()
1254 static struct alsa_input_node *new_input(struct alsa_io *aio, in new_input() argument
1257 struct cras_iodev *iodev = &aio->base; in new_input()
1267 input->base.dev = &aio->base; in new_input()
1268 input->base.idx = aio->next_ionode_index++; in new_input()
1271 aio->base.info.stable_id); in new_input()
1274 aio->base.info.stable_id_new); in new_input()
1277 set_node_initial_state(&input->base, aio->card_type); in new_input()
1278 set_input_node_software_volume_needed(input, aio); in new_input()
1279 set_input_default_node_gain(input, aio); in new_input()
1281 if (aio->ucm) { in new_input()
1285 mic_positions = ucm_get_mic_positions(aio->ucm); in new_input()
1297 err = ucm_get_capture_chmap_for_dev(aio->ucm, name, in new_input()
1303 if (ucm_get_preempt_hotword(aio->ucm, name)) { in new_input()
1311 cras_iodev_add_node(&aio->base, &input->base); in new_input()
1312 check_auto_unplug_input_node(aio, &input->base, in new_input()
1320 struct alsa_io *aio = (struct alsa_io *)callback_arg; in new_input_by_mixer_control() local
1324 if (aio->card_type == ALSA_CARD_TYPE_USB) { in new_input_by_mixer_control()
1326 aio->base.info.name, ctl_name); in new_input_by_mixer_control()
1330 new_input(aio, cras_input, node_name); in new_input_by_mixer_control()
1332 new_input(aio, cras_input, ctl_name); in new_input_by_mixer_control()
1340 struct alsa_io *aio, const struct cras_alsa_jack *jack) in get_output_node_from_jack() argument
1347 DL_SEARCH_SCALAR_WITH_CAST(aio->base.nodes, node, aout, in get_output_node_from_jack()
1357 DL_SEARCH_SCALAR_WITH_CAST(aio->base.nodes, node, aout, in get_output_node_from_jack()
1363 struct alsa_io *aio, const struct cras_alsa_jack *jack) in get_input_node_from_jack() argument
1371 DL_SEARCH_SCALAR_WITH_CAST(aio->base.nodes, node, ain, in get_input_node_from_jack()
1376 DL_SEARCH_SCALAR_WITH_CAST(aio->base.nodes, node, ain, in get_input_node_from_jack()
1401 static const char *get_active_dsp_name(struct alsa_io *aio) in get_active_dsp_name() argument
1403 struct cras_ionode *node = aio->base.active_node; in get_active_dsp_name()
1409 if (aio->base.direction == CRAS_STREAM_OUTPUT) in get_active_dsp_name()
1414 return cras_alsa_jack_get_dsp_name(jack) ? : aio->dsp_name_default; in get_active_dsp_name()
1449 struct alsa_io *aio; in jack_output_plug_event() local
1456 aio = (struct alsa_io *)arg; in jack_output_plug_event()
1457 node = get_output_node_from_jack(aio, jack); in jack_output_plug_event()
1464 if (aio->fully_specified) { in jack_output_plug_event()
1470 node = new_output(aio, NULL, jack_name); in jack_output_plug_event()
1478 if (aio->fully_specified) in jack_output_plug_event()
1488 aio->config, jack); in jack_output_plug_event()
1505 check_auto_unplug_output_node(aio, &node->base, plugged); in jack_output_plug_event()
1515 struct alsa_io *aio; in jack_input_plug_event() local
1522 aio = (struct alsa_io *)arg; in jack_input_plug_event()
1523 node = get_input_node_from_jack(aio, jack); in jack_input_plug_event()
1528 if (aio->fully_specified) { in jack_input_plug_event()
1535 node = new_input(aio, cras_input, jack_name); in jack_input_plug_event()
1545 if (aio->fully_specified) in jack_input_plug_event()
1555 check_auto_unplug_input_node(aio, &node->base, plugged); in jack_input_plug_event()
1616 static int get_fixed_rate(struct alsa_io *aio) in get_fixed_rate() argument
1620 if (aio->base.direction == CRAS_STREAM_OUTPUT) { in get_fixed_rate()
1621 struct alsa_output_node *active = get_active_output(aio); in get_fixed_rate()
1626 struct alsa_input_node *active = get_active_input(aio); in get_fixed_rate()
1632 return ucm_get_sample_rate_for_dev(aio->ucm, name, aio->base.direction); in get_fixed_rate()
1640 struct alsa_io *aio = (struct alsa_io *)iodev; in update_supported_formats() local
1651 err = cras_alsa_fill_properties(aio->handle, in update_supported_formats()
1658 if (aio->ucm) { in update_supported_formats()
1660 fixed_rate = get_fixed_rate(aio); in update_supported_formats()
1675 static void build_softvol_scalers(struct alsa_io *aio) in build_softvol_scalers() argument
1679 DL_FOREACH(aio->base.nodes, ionode) { in build_softvol_scalers()
1684 curve = get_curve_for_output_node(aio, aout); in build_softvol_scalers()
1690 static void enable_active_ucm(struct alsa_io *aio, int plugged) in enable_active_ucm() argument
1695 if (aio->base.direction == CRAS_STREAM_OUTPUT) { in enable_active_ucm()
1696 struct alsa_output_node *active = get_active_output(aio); in enable_active_ucm()
1702 struct alsa_input_node *active = get_active_input(aio); in enable_active_ucm()
1711 else if (aio->ucm) in enable_active_ucm()
1712 ucm_set_enabled(aio->ucm, name, plugged); in enable_active_ucm()
1717 struct alsa_io *aio = (struct alsa_io *)iodev; in fill_whole_buffer_with_zeros() local
1723 rc = cras_alsa_mmap_get_whole_buffer(aio->handle, &dst); in fill_whole_buffer_with_zeros()
1739 struct alsa_io *aio = (struct alsa_io *)odev; in adjust_appl_ptr() local
1745 aio->handle, in adjust_appl_ptr()
1755 struct alsa_io *aio = (struct alsa_io *)odev; in adjust_appl_ptr_samples_remaining() local
1776 if (real_hw_level > aio->filled_zeros_for_draining) in adjust_appl_ptr_samples_remaining()
1777 valid_sample = real_hw_level - aio->filled_zeros_for_draining; in adjust_appl_ptr_samples_remaining()
1787 return cras_alsa_resume_appl_ptr(aio->handle, offset); in adjust_appl_ptr_samples_remaining()
1792 struct alsa_io *aio = (struct alsa_io *)odev; in alsa_output_underrun() local
1796 aio->num_underruns++; in alsa_output_underrun()
1809 struct alsa_io *aio = (struct alsa_io *)odev; in possibly_enter_free_run() local
1815 if (aio->is_free_running) in possibly_enter_free_run()
1831 aio->is_free_running = 1; in possibly_enter_free_run()
1835 if (real_hw_level <= aio->filled_zeros_for_draining || real_hw_level == 0) { in possibly_enter_free_run()
1839 aio->is_free_running = 1; in possibly_enter_free_run()
1850 aio->filled_zeros_for_draining += fr_to_write; in possibly_enter_free_run()
1858 struct alsa_io *aio = (struct alsa_io *)odev; in leave_free_run() local
1861 if (aio->is_free_running) in leave_free_run()
1870 aio->is_free_running = 0; in leave_free_run()
1871 aio->filled_zeros_for_draining = 0; in leave_free_run()
1892 struct alsa_io *aio = (struct alsa_io *)odev; in output_should_wake() local
1893 if (aio->is_free_running) in output_should_wake()
1904 const struct alsa_io *aio = (const struct alsa_io *)iodev; in get_num_underruns() local
1905 return aio->num_underruns; in get_num_underruns()
1910 const struct alsa_io *aio = (const struct alsa_io *)iodev; in get_num_severe_underruns() local
1911 return aio->num_severe_underruns; in get_num_severe_underruns()
1948 struct alsa_io *aio; in alsa_iodev_create() local
1954 aio = (struct alsa_io *)calloc(1, sizeof(*aio)); in alsa_iodev_create()
1955 if (!aio) in alsa_iodev_create()
1957 iodev = &aio->base; in alsa_iodev_create()
1960 aio->device_index = device_index; in alsa_iodev_create()
1961 aio->card_type = card_type; in alsa_iodev_create()
1962 aio->is_first = is_first; in alsa_iodev_create()
1963 aio->handle = NULL; in alsa_iodev_create()
1964 aio->num_severe_underruns = 0; in alsa_iodev_create()
1966 aio->dev_name = strdup(dev_name); in alsa_iodev_create()
1967 if (!aio->dev_name) in alsa_iodev_create()
1971 aio->dev_id = strdup(dev_id); in alsa_iodev_create()
1972 if (!aio->dev_id) in alsa_iodev_create()
1975 aio->is_free_running = 0; in alsa_iodev_create()
1976 aio->filled_zeros_for_draining = 0; in alsa_iodev_create()
1977 aio->dev = (char *)malloc(MAX_ALSA_DEV_NAME_LENGTH); in alsa_iodev_create()
1978 if (aio->dev == NULL) in alsa_iodev_create()
1980 snprintf(aio->dev, in alsa_iodev_create()
1987 aio->alsa_stream = SND_PCM_STREAM_CAPTURE; in alsa_iodev_create()
1988 aio->base.set_capture_gain = set_alsa_capture_gain; in alsa_iodev_create()
1989 aio->base.set_capture_mute = set_alsa_capture_gain; in alsa_iodev_create()
1991 aio->alsa_stream = SND_PCM_STREAM_PLAYBACK; in alsa_iodev_create()
1992 aio->base.set_volume = set_alsa_volume; in alsa_iodev_create()
1993 aio->base.set_mute = set_alsa_mute; in alsa_iodev_create()
1994 aio->base.output_underrun = alsa_output_underrun; in alsa_iodev_create()
2023 aio->mixer = mixer; in alsa_iodev_create()
2024 aio->config = config; in alsa_iodev_create()
2026 aio->default_volume_curve = in alsa_iodev_create()
2029 if (aio->default_volume_curve == NULL) in alsa_iodev_create()
2030 aio->default_volume_curve = in alsa_iodev_create()
2033 aio->ucm = ucm; in alsa_iodev_create()
2038 aio->dsp_name_default = ucm_get_dsp_name_default(ucm, in alsa_iodev_create()
2043 aio->base.set_swap_mode_for_node = in alsa_iodev_create()
2050 aio->enable_htimestamp = in alsa_iodev_create()
2057 aio->jack_list = in alsa_iodev_create()
2070 aio); in alsa_iodev_create()
2071 if (!aio->jack_list) in alsa_iodev_create()
2081 cras_iodev_list_add_output(&aio->base); in alsa_iodev_create()
2083 cras_iodev_list_add_input(&aio->base); in alsa_iodev_create()
2084 return &aio->base; in alsa_iodev_create()
2087 free_alsa_iodev_resources(aio); in alsa_iodev_create()
2088 free(aio); in alsa_iodev_create()
2094 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_legacy_complete_init() local
2102 if (!aio) in alsa_iodev_legacy_complete_init()
2105 dev_name = aio->dev_name; in alsa_iodev_legacy_complete_init()
2106 dev_id = aio->dev_id; in alsa_iodev_legacy_complete_init()
2107 is_first = aio->is_first; in alsa_iodev_legacy_complete_init()
2108 mixer = aio->mixer; in alsa_iodev_legacy_complete_init()
2114 new_output_by_mixer_control, aio); in alsa_iodev_legacy_complete_init()
2117 new_input_by_mixer_control, aio); in alsa_iodev_legacy_complete_init()
2119 err = cras_alsa_jack_list_find_jacks_by_name_matching(aio->jack_list); in alsa_iodev_legacy_complete_init()
2126 cras_alsa_jack_list_report(aio->jack_list); in alsa_iodev_legacy_complete_init()
2134 !no_create_default_output_node(aio)) { in alsa_iodev_legacy_complete_init()
2135 if (first_internal_device(aio) && in alsa_iodev_legacy_complete_init()
2136 !has_node(aio, INTERNAL_SPEAKER) && in alsa_iodev_legacy_complete_init()
2137 !has_node(aio, HDMI)) { in alsa_iodev_legacy_complete_init()
2138 if (strstr(aio->base.info.name, HDMI)) in alsa_iodev_legacy_complete_init()
2139 new_output(aio, NULL, HDMI); in alsa_iodev_legacy_complete_init()
2141 new_output(aio, NULL, INTERNAL_SPEAKER); in alsa_iodev_legacy_complete_init()
2142 } else if (!aio->base.nodes) { in alsa_iodev_legacy_complete_init()
2143 new_output(aio, NULL, DEFAULT); in alsa_iodev_legacy_complete_init()
2146 !no_create_default_input_node(aio)) { in alsa_iodev_legacy_complete_init()
2147 if (first_internal_device(aio) && in alsa_iodev_legacy_complete_init()
2148 !has_node(aio, INTERNAL_MICROPHONE)) in alsa_iodev_legacy_complete_init()
2149 new_input(aio, NULL, INTERNAL_MICROPHONE); in alsa_iodev_legacy_complete_init()
2151 new_input(aio, NULL, KEYBOARD_MIC); in alsa_iodev_legacy_complete_init()
2153 new_input(aio, NULL, HOTWORD_DEV); in alsa_iodev_legacy_complete_init()
2154 else if (!aio->base.nodes) in alsa_iodev_legacy_complete_init()
2155 new_input(aio, NULL, DEFAULT); in alsa_iodev_legacy_complete_init()
2160 build_softvol_scalers(aio); in alsa_iodev_legacy_complete_init()
2163 alsa_iodev_set_active_node(&aio->base, in alsa_iodev_legacy_complete_init()
2164 first_plugged_node(&aio->base), in alsa_iodev_legacy_complete_init()
2169 if (aio->card_type == ALSA_CARD_TYPE_USB && is_first && in alsa_iodev_legacy_complete_init()
2182 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_ucm_add_nodes_and_jacks() local
2189 if (!aio || !section) in alsa_iodev_ucm_add_nodes_and_jacks()
2191 if ((uint32_t)section->dev_idx != aio->device_index) in alsa_iodev_ucm_add_nodes_and_jacks()
2195 aio->fully_specified = 1; in alsa_iodev_ucm_add_nodes_and_jacks()
2199 if (!aio->dma_period_set_microsecs) in alsa_iodev_ucm_add_nodes_and_jacks()
2200 aio->dma_period_set_microsecs = in alsa_iodev_ucm_add_nodes_and_jacks()
2201 ucm_get_dma_period_for_dev(aio->ucm, section->name); in alsa_iodev_ucm_add_nodes_and_jacks()
2205 control = cras_alsa_mixer_get_control_for_section(aio->mixer, section); in alsa_iodev_ucm_add_nodes_and_jacks()
2207 output_node = new_output(aio, control, section->name); in alsa_iodev_ucm_add_nodes_and_jacks()
2211 input_node = new_input(aio, control, section->name); in alsa_iodev_ucm_add_nodes_and_jacks()
2218 aio->jack_list, section, &jack); in alsa_iodev_ucm_add_nodes_and_jacks()
2229 aio->config, jack); in alsa_iodev_ucm_add_nodes_and_jacks()
2239 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_ucm_complete_init() local
2245 cras_alsa_jack_list_report(aio->jack_list); in alsa_iodev_ucm_complete_init()
2249 build_softvol_scalers(aio); in alsa_iodev_ucm_complete_init()
2252 alsa_iodev_set_active_node(&aio->base, in alsa_iodev_ucm_complete_init()
2253 first_plugged_node(&aio->base), in alsa_iodev_ucm_complete_init()
2258 if (aio->card_type == ALSA_CARD_TYPE_USB && aio->is_first && in alsa_iodev_ucm_complete_init()
2268 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_destroy() local
2271 cras_alsa_jack_list_destroy(aio->jack_list); in alsa_iodev_destroy()
2283 free_alsa_iodev_resources(aio); in alsa_iodev_destroy()
2284 cras_volume_curve_destroy(aio->default_volume_curve); in alsa_iodev_destroy()
2290 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_index() local
2291 return aio->device_index; in alsa_iodev_index()
2296 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_has_hctl_jacks() local
2297 return cras_alsa_jack_list_has_hctl_jacks(aio->jack_list); in alsa_iodev_has_hctl_jacks()
2300 static void alsa_iodev_unmute_node(struct alsa_io *aio, in alsa_iodev_unmute_node() argument
2312 set_alsa_mute_control(aio, 1); in alsa_iodev_unmute_node()
2314 DL_FOREACH(aio->base.nodes, node) { in alsa_iodev_unmute_node()
2327 struct alsa_io *aio = (struct alsa_io *)iodev; in alsa_iodev_set_active_node() local
2330 enable_active_ucm(aio, dev_enabled); in alsa_iodev_set_active_node()
2331 init_device_settings(aio); in alsa_iodev_set_active_node()
2336 enable_active_ucm(aio, 0); in alsa_iodev_set_active_node()
2338 alsa_iodev_unmute_node(aio, ionode); in alsa_iodev_set_active_node()
2341 aio->base.dsp_name = get_active_dsp_name(aio); in alsa_iodev_set_active_node()
2343 enable_active_ucm(aio, dev_enabled); in alsa_iodev_set_active_node()
2345 init_device_settings(aio); in alsa_iodev_set_active_node()