Lines Matching refs:adev
440 static int open_hdmi_driver(struct audio_device *adev) in open_hdmi_driver() argument
442 if (adev->hdmi_drv_fd < 0) { in open_hdmi_driver()
443 adev->hdmi_drv_fd = open("/dev/video16", O_RDWR); in open_hdmi_driver()
444 if (adev->hdmi_drv_fd < 0) in open_hdmi_driver()
445 ALOGE("%s cannot open video16 (%d)", __func__, adev->hdmi_drv_fd); in open_hdmi_driver()
447 return adev->hdmi_drv_fd; in open_hdmi_driver()
451 static int enable_hdmi_audio(struct audio_device *adev, int enable) in enable_hdmi_audio() argument
456 ret = open_hdmi_driver(adev); in enable_hdmi_audio()
462 ret = ioctl(adev->hdmi_drv_fd, VIDIOC_S_CTRL, &ctrl); in enable_hdmi_audio()
474 static int read_hdmi_channel_masks(struct audio_device *adev, struct stream_out *out) { in read_hdmi_channel_masks() argument
478 ret = open_hdmi_driver(adev); in read_hdmi_channel_masks()
483 ret = ioctl(adev->hdmi_drv_fd, VIDIOC_G_CTRL, &ctrl); in read_hdmi_channel_masks()
502 static int set_hdmi_channels(struct audio_device *adev, int channels) { in set_hdmi_channels() argument
506 ret = open_hdmi_driver(adev); in set_hdmi_channels()
512 ret = ioctl(adev->hdmi_drv_fd, VIDIOC_S_CTRL, &ctrl); in set_hdmi_channels()
520 static void select_devices(struct audio_device *adev) in select_devices() argument
522 int output_device_id = get_output_device_id(adev->out_device); in select_devices()
523 int input_source_id = get_input_source_id(adev->input_source); in select_devices()
529 audio_route_reset(adev->ar); in select_devices()
531 enable_hdmi_audio(adev, adev->out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL); in select_devices()
534 if ((new_route_id == adev->cur_route_id) && (adev->es305_mode == adev->es305_new_mode)) in select_devices()
536 adev->cur_route_id = new_route_id; in select_devices()
537 adev->es305_mode = adev->es305_new_mode; in select_devices()
546 route_configs[input_source_id][output_device_id]->es305_preset[adev->es305_mode]; in select_devices()
548 switch (adev->in_device) { in select_devices()
562 route_configs[input_source_id][output_device_id]->es305_preset[adev->es305_mode]; in select_devices()
565 if ((adev->input_source == AUDIO_SOURCE_VOICE_RECOGNITION) && in select_devices()
566 (adev->in_channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)) in select_devices()
576 adev->out_device, adev->input_source, in select_devices()
581 audio_route_apply_path(adev->ar, output_route); in select_devices()
583 audio_route_apply_path(adev->ar, input_route); in select_devices()
586 (new_es305_preset != adev->es305_preset)) { in select_devices()
588 adev->es305_preset, new_es305_preset); in select_devices()
590 adev->es305_preset = new_es305_preset; in select_devices()
594 audio_route_update_mixer(adev->ar); in select_devices()
600 struct audio_device *adev = (struct audio_device *)user_data; in bubblelevel_callback() local
608 pthread_mutex_lock(&adev->lock); in bubblelevel_callback()
609 if (es305_mode != adev->es305_mode) { in bubblelevel_callback()
610 adev->es305_new_mode = es305_mode; in bubblelevel_callback()
611 select_devices(adev); in bubblelevel_callback()
614 pthread_mutex_unlock(&adev->lock); in bubblelevel_callback()
618 bool get_bubblelevel(struct audio_device *adev) in get_bubblelevel() argument
620 if (!adev->bubble_level) { in get_bubblelevel()
621 adev->bubble_level = bubble_level_create(); in get_bubblelevel()
622 if (adev->bubble_level) in get_bubblelevel()
623 adev->bubble_level->set_callback(adev->bubble_level, bubblelevel_callback, adev); in get_bubblelevel()
625 return (adev->bubble_level != NULL); in get_bubblelevel()
629 static void force_non_hdmi_out_standby(struct audio_device *adev) in force_non_hdmi_out_standby() argument
635 out = adev->outputs[type]; in force_non_hdmi_out_standby()
644 static void start_bt_sco(struct audio_device *adev) { in start_bt_sco() argument
645 if (adev->sco_on_count++ > 0) in start_bt_sco()
648 adev->pcm_voice_out = pcm_open(PCM_CARD, PCM_DEVICE_VOICE, PCM_OUT | PCM_MONOTONIC, in start_bt_sco()
650 if (adev->pcm_voice_out && !pcm_is_ready(adev->pcm_voice_out)) { in start_bt_sco()
651 ALOGE("pcm_open(VOICE_OUT) failed: %s", pcm_get_error(adev->pcm_voice_out)); in start_bt_sco()
654 adev->pcm_sco_out = pcm_open(PCM_CARD, PCM_DEVICE_SCO, PCM_OUT | PCM_MONOTONIC, in start_bt_sco()
656 if (adev->pcm_sco_out && !pcm_is_ready(adev->pcm_sco_out)) { in start_bt_sco()
657 ALOGE("pcm_open(SCO_OUT) failed: %s", pcm_get_error(adev->pcm_sco_out)); in start_bt_sco()
660 adev->pcm_voice_in = pcm_open(PCM_CARD, PCM_DEVICE_VOICE, PCM_IN, in start_bt_sco()
662 if (adev->pcm_voice_in && !pcm_is_ready(adev->pcm_voice_in)) { in start_bt_sco()
663 ALOGE("pcm_open(VOICE_IN) failed: %s", pcm_get_error(adev->pcm_voice_in)); in start_bt_sco()
666 adev->pcm_sco_in = pcm_open(PCM_CARD, PCM_DEVICE_SCO, PCM_IN, in start_bt_sco()
668 if (adev->pcm_sco_in && !pcm_is_ready(adev->pcm_sco_in)) { in start_bt_sco()
669 ALOGE("pcm_open(SCO_IN) failed: %s", pcm_get_error(adev->pcm_sco_in)); in start_bt_sco()
673 pcm_start(adev->pcm_voice_out); in start_bt_sco()
674 pcm_start(adev->pcm_sco_out); in start_bt_sco()
675 pcm_start(adev->pcm_voice_in); in start_bt_sco()
676 pcm_start(adev->pcm_sco_in); in start_bt_sco()
681 pcm_close(adev->pcm_sco_in); in start_bt_sco()
683 pcm_close(adev->pcm_voice_in); in start_bt_sco()
685 pcm_close(adev->pcm_sco_out); in start_bt_sco()
687 pcm_close(adev->pcm_voice_out); in start_bt_sco()
691 static void stop_bt_sco(struct audio_device *adev) { in stop_bt_sco() argument
692 if (adev->sco_on_count == 0 || --adev->sco_on_count > 0) in stop_bt_sco()
695 pcm_stop(adev->pcm_voice_out); in stop_bt_sco()
696 pcm_stop(adev->pcm_sco_out); in stop_bt_sco()
697 pcm_stop(adev->pcm_voice_in); in stop_bt_sco()
698 pcm_stop(adev->pcm_sco_in); in stop_bt_sco()
700 pcm_close(adev->pcm_voice_out); in stop_bt_sco()
701 pcm_close(adev->pcm_sco_out); in stop_bt_sco()
702 pcm_close(adev->pcm_voice_in); in stop_bt_sco()
703 pcm_close(adev->pcm_sco_in); in stop_bt_sco()
709 struct audio_device *adev = out->dev; in start_output_stream() local
712 if (out == adev->outputs[OUTPUT_HDMI]) { in start_output_stream()
713 force_non_hdmi_out_standby(adev); in start_output_stream()
714 } else if (adev->outputs[OUTPUT_HDMI] && !adev->outputs[OUTPUT_HDMI]->standby) { in start_output_stream()
751 adev->out_device |= out->device; in start_output_stream()
752 select_devices(adev); in start_output_stream()
755 start_bt_sco(adev); in start_output_stream()
758 set_hdmi_channels(adev, out->config.channels); in start_output_stream()
761 if (get_bubblelevel(adev)) in start_output_stream()
762 adev->bubble_level->poll_once(adev->bubble_level); in start_output_stream()
770 struct audio_device *adev = in->dev; in start_input_stream() local
785 adev->input_source = in->input_source; in start_input_stream()
786 adev->in_device = in->device; in start_input_stream()
787 adev->in_channel_mask = in->channel_mask; in start_input_stream()
790 select_devices(adev); in start_input_stream()
793 start_bt_sco(adev); in start_input_stream()
800 if (get_bubblelevel(adev)) { in start_input_stream()
801 adev->bubble_level->set_poll_interval(adev->bubble_level, BL_POLL_INTERVAL_MIN_SEC); in start_input_stream()
802 adev->bubble_level->start_polling(adev->bubble_level); in start_input_stream()
995 struct audio_device *adev = out->dev; in do_out_standby() local
1007 if (out == adev->outputs[OUTPUT_HDMI]) { in do_out_standby()
1010 force_non_hdmi_out_standby(adev); in do_out_standby()
1014 stop_bt_sco(adev); in do_out_standby()
1017 adev->out_device = output_devices(out); in do_out_standby()
1020 if (adev->out_device) in do_out_standby()
1021 select_devices(adev); in do_out_standby()
1026 static void lock_all_outputs(struct audio_device *adev) in lock_all_outputs() argument
1029 pthread_mutex_lock(&adev->lock_outputs); in lock_all_outputs()
1031 struct stream_out *out = adev->outputs[type]; in lock_all_outputs()
1035 pthread_mutex_lock(&adev->lock); in lock_all_outputs()
1039 static void unlock_all_outputs(struct audio_device *adev, struct stream_out *except) in unlock_all_outputs() argument
1042 pthread_mutex_unlock(&adev->lock); in unlock_all_outputs()
1045 struct stream_out *out = adev->outputs[--type]; in unlock_all_outputs()
1049 pthread_mutex_unlock(&adev->lock_outputs); in unlock_all_outputs()
1055 struct audio_device *adev = out->dev; in out_standby() local
1057 lock_all_outputs(adev); in out_standby()
1061 unlock_all_outputs(adev, NULL); in out_standby()
1074 struct audio_device *adev = out->dev; in out_set_parameters() local
1084 lock_all_outputs(adev); in out_set_parameters()
1091 (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) || in out_set_parameters()
1092 (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) { in out_set_parameters()
1102 if (!out->standby && (out == adev->outputs[OUTPUT_HDMI] || in out_set_parameters()
1103 !adev->outputs[OUTPUT_HDMI] || in out_set_parameters()
1104 adev->outputs[OUTPUT_HDMI]->standby)) { in out_set_parameters()
1105 adev->out_device = output_devices(out) | val; in out_set_parameters()
1106 select_devices(adev); in out_set_parameters()
1111 unlock_all_outputs(adev, NULL); in out_set_parameters()
1169 struct audio_device *adev = out->dev; in out_set_volume() local
1175 bool is_HDMI = out == adev->outputs[OUTPUT_HDMI]; in out_set_volume()
1190 struct audio_device *adev = out->dev; in out_write() local
1202 lock_all_outputs(adev); in out_write()
1204 unlock_all_outputs(adev, out); in out_write()
1209 unlock_all_outputs(adev, NULL); in out_write()
1213 unlock_all_outputs(adev, out); in out_write()
1347 struct audio_device *adev = in->dev; in do_in_standby() local
1354 stop_bt_sco(adev); in do_in_standby()
1359 select_devices(adev); in do_in_standby()
1362 if (get_bubblelevel(adev)) in do_in_standby()
1363 in->dev->bubble_level->stop_polling(adev->bubble_level); in do_in_standby()
1392 struct audio_device *adev = in->dev; in in_set_parameters() local
1402 pthread_mutex_lock(&adev->lock); in in_set_parameters()
1432 adev->input_source = in->input_source; in in_set_parameters()
1433 adev->in_device = in->device; in in_set_parameters()
1434 select_devices(adev); in in_set_parameters()
1437 pthread_mutex_unlock(&adev->lock); in in_set_parameters()
1487 struct audio_device *adev = in->dev; in in_read() local
1498 pthread_mutex_lock(&adev->lock); in in_read()
1500 pthread_mutex_unlock(&adev->lock); in in_read()
1521 if (ret == 0 && adev->mic_mute) in in_read()
1584 struct audio_device *adev = (struct audio_device *)dev; in adev_open_output_stream() local
1601 pthread_mutex_lock(&adev->lock); in adev_open_output_stream()
1602 ret = read_hdmi_channel_masks(adev, out); in adev_open_output_stream()
1603 pthread_mutex_unlock(&adev->lock); in adev_open_output_stream()
1645 out->dev = adev; in adev_open_output_stream()
1655 pthread_mutex_lock(&adev->lock_outputs); in adev_open_output_stream()
1656 if (adev->outputs[type]) { in adev_open_output_stream()
1657 pthread_mutex_unlock(&adev->lock_outputs); in adev_open_output_stream()
1661 adev->outputs[type] = out; in adev_open_output_stream()
1662 pthread_mutex_unlock(&adev->lock_outputs); in adev_open_output_stream()
1677 struct audio_device *adev; in adev_close_output_stream() local
1681 adev = (struct audio_device *)dev; in adev_close_output_stream()
1682 pthread_mutex_lock(&adev->lock_outputs); in adev_close_output_stream()
1684 if (adev->outputs[type] == (struct stream_out *) stream) { in adev_close_output_stream()
1685 adev->outputs[type] = NULL; in adev_close_output_stream()
1689 pthread_mutex_unlock(&adev->lock_outputs); in adev_close_output_stream()
1701 struct audio_device *adev = (struct audio_device *)dev; in adev_get_parameters() local
1739 struct audio_device *adev = (struct audio_device *)dev; in adev_set_mic_mute() local
1741 adev->mic_mute = state; in adev_set_mic_mute()
1748 struct audio_device *adev = (struct audio_device *)dev; in adev_get_mic_mute() local
1750 *state = adev->mic_mute; in adev_get_mic_mute()
1773 struct audio_device *adev = (struct audio_device *)dev; in adev_open_input_stream() local
1806 in->dev = adev; in adev_open_input_stream()
1874 struct audio_device *adev = (struct audio_device *)device; in adev_close() local
1876 audio_route_free(adev->ar); in adev_close()
1880 if (adev->hdmi_drv_fd >= 0) in adev_close()
1881 close(adev->hdmi_drv_fd); in adev_close()
1883 if (adev->bubble_level) in adev_close()
1884 bubble_level_release(adev->bubble_level); in adev_close()
1893 struct audio_device *adev; in adev_open() local
1899 adev = calloc(1, sizeof(struct audio_device)); in adev_open()
1900 if (!adev) in adev_open()
1903 adev->hw_device.common.tag = HARDWARE_DEVICE_TAG; in adev_open()
1904 adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_2_0; in adev_open()
1905 adev->hw_device.common.module = (struct hw_module_t *) module; in adev_open()
1906 adev->hw_device.common.close = adev_close; in adev_open()
1908 adev->hw_device.init_check = adev_init_check; in adev_open()
1909 adev->hw_device.set_voice_volume = adev_set_voice_volume; in adev_open()
1910 adev->hw_device.set_master_volume = adev_set_master_volume; in adev_open()
1911 adev->hw_device.set_mode = adev_set_mode; in adev_open()
1912 adev->hw_device.set_mic_mute = adev_set_mic_mute; in adev_open()
1913 adev->hw_device.get_mic_mute = adev_get_mic_mute; in adev_open()
1914 adev->hw_device.set_parameters = adev_set_parameters; in adev_open()
1915 adev->hw_device.get_parameters = adev_get_parameters; in adev_open()
1916 adev->hw_device.get_input_buffer_size = adev_get_input_buffer_size; in adev_open()
1917 adev->hw_device.open_output_stream = adev_open_output_stream; in adev_open()
1918 adev->hw_device.close_output_stream = adev_close_output_stream; in adev_open()
1919 adev->hw_device.open_input_stream = adev_open_input_stream; in adev_open()
1920 adev->hw_device.close_input_stream = adev_close_input_stream; in adev_open()
1921 adev->hw_device.dump = adev_dump; in adev_open()
1923 adev->ar = audio_route_init(MIXER_CARD, NULL); in adev_open()
1924 adev->input_source = AUDIO_SOURCE_DEFAULT; in adev_open()
1928 adev->es305_preset = ES305_PRESET_INIT; in adev_open()
1929 adev->es305_new_mode = ES305_MODE_LEVEL; in adev_open()
1930 adev->es305_mode = ES305_MODE_LEVEL; in adev_open()
1931 adev->hdmi_drv_fd = -1; in adev_open()
1933 *device = &adev->hw_device.common; in adev_open()