Home | History | Annotate | Download | only in audio

Lines Matching full:adev

424 static int open_hdmi_driver(struct audio_device *adev)
426 if (adev->hdmi_drv_fd < 0) {
427 adev->hdmi_drv_fd = open("/dev/video16", O_RDWR);
428 if (adev->hdmi_drv_fd < 0)
429 ALOGE("%s cannot open video16 (%d)", __func__, adev->hdmi_drv_fd);
431 return adev->hdmi_drv_fd;
435 static int enable_hdmi_audio(struct audio_device *adev, int enable)
440 ret = open_hdmi_driver(adev);
446 ret = ioctl(adev->hdmi_drv_fd, VIDIOC_S_CTRL, &ctrl);
455 static int read_hdmi_channel_masks(struct audio_device *adev, struct stream_out *out) {
459 ret = open_hdmi_driver(adev);
464 ret = ioctl(adev->hdmi_drv_fd, VIDIOC_G_CTRL, &ctrl);
483 static int set_hdmi_channels(struct audio_device *adev, int channels) {
487 ret = open_hdmi_driver(adev);
493 ret = ioctl(adev->hdmi_drv_fd, VIDIOC_S_CTRL, &ctrl);
500 static void select_devices(struct audio_device *adev)
502 int output_device_id = get_output_device_id(adev->out_device);
503 int input_source_id = get_input_source_id(adev->input_source);
509 audio_route_reset(adev->ar);
511 enable_hdmi_audio(adev, adev->out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL);
514 if ((new_route_id == adev->cur_route_id) && (adev->es305_mode == adev->es305_new_mode))
516 adev->cur_route_id = new_route_id;
517 adev->es305_mode = adev->es305_new_mode;
526 route_configs[input_source_id][output_device_id]->es305_preset[adev->es305_mode];
528 switch (adev->in_device) {
542 route_configs[input_source_id][output_device_id]->es305_preset[adev->es305_mode];
545 if ((adev->input_source == AUDIO_SOURCE_VOICE_RECOGNITION) &&
546 (adev->in_channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK))
556 adev->out_device, adev->input_source,
561 audio_route_apply_path(adev->ar, output_route);
563 audio_route_apply_path(adev->ar, input_route);
566 (new_es305_preset != adev->es305_preset)) {
568 adev->es305_preset, new_es305_preset);
570 adev->es305_preset = new_es305_preset;
574 audio_route_update_mixer(adev->ar);
579 struct audio_device *adev = (struct audio_device *)user_data;
587 pthread_mutex_lock(&adev->lock);
588 if (es305_mode != adev->es305_mode) {
589 adev->es305_new_mode = es305_mode;
590 select_devices(adev);
593 pthread_mutex_unlock(&adev->lock);
597 bool get_bubblelevel(struct audio_device *adev)
599 if (!adev->bubble_level) {
600 adev->bubble_level = bubble_level_create();
601 if (adev->bubble_level)
602 adev->bubble_level->set_callback(adev->bubble_level, bubblelevel_callback, adev);
604 return (adev->bubble_level != NULL);
607 static void force_non_hdmi_out_standby(struct audio_device *adev)
613 out = adev->outputs[type];
623 static void start_bt_sco(struct audio_device *adev) {
624 if (adev->sco_on_count++ > 0)
627 adev->pcm_voice_out = pcm_open(PCM_CARD, PCM_DEVICE_VOICE, PCM_OUT | PCM_MONOTONIC,
629 if (adev->pcm_voice_out && !pcm_is_ready(adev->pcm_voice_out)) {
630 ALOGE("pcm_open(VOICE_OUT) failed: %s", pcm_get_error(adev->pcm_voice_out));
633 adev->pcm_sco_out = pcm_open(PCM_CARD, PCM_DEVICE_SCO, PCM_OUT | PCM_MONOTONIC,
635 if (adev->pcm_sco_out && !pcm_is_ready(adev->pcm_sco_out)) {
636 ALOGE("pcm_open(SCO_OUT) failed: %s", pcm_get_error(adev->pcm_sco_out));
639 adev->pcm_voice_in = pcm_open(PCM_CARD, PCM_DEVICE_VOICE, PCM_IN,
641 if (adev->pcm_voice_in && !pcm_is_ready(adev->pcm_voice_in)) {
642 ALOGE("pcm_open(VOICE_IN) failed: %s", pcm_get_error(adev->pcm_voice_in));
645 adev->pcm_sco_in = pcm_open(PCM_CARD, PCM_DEVICE_SCO, PCM_IN,
647 if (adev->pcm_sco_in && !pcm_is_ready(adev->pcm_sco_in)) {
648 ALOGE("pcm_open(SCO_IN) failed: %s", pcm_get_error(adev->pcm_sco_in));
652 pcm_start(adev->pcm_voice_out);
653 pcm_start(adev->pcm_sco_out);
654 pcm_start(adev->pcm_voice_in);
655 pcm_start(adev->pcm_sco_in);
660 pcm_close(adev->pcm_sco_in);
662 pcm_close(adev->pcm_voice_in);
664 pcm_close(adev->pcm_sco_out);
666 pcm_close(adev->pcm_voice_out);
670 static void stop_bt_sco(struct audio_device *adev) {
671 if (adev->sco_on_count == 0 || --adev->sco_on_count > 0)
674 pcm_stop(adev->pcm_voice_out);
675 pcm_stop(adev->pcm_sco_out);
676 pcm_stop(adev->pcm_voice_in);
677 pcm_stop(adev->pcm_sco_in);
679 pcm_close(adev->pcm_voice_out);
680 pcm_close(adev->pcm_sco_out);
681 pcm_close(adev->pcm_voice_in);
682 pcm_close(adev->pcm_sco_in);
688 struct audio_device *adev = out->dev;
691 if (out == adev->outputs[OUTPUT_HDMI]) {
692 force_non_hdmi_out_standby(adev);
693 } else if (adev->outputs[OUTPUT_HDMI] && !adev->outputs[OUTPUT_HDMI]->standby) {
730 adev->out_device |= out->device;
731 select_devices(adev);
734 start_bt_sco(adev);
737 set_hdmi_channels(adev, out->config.channels);
740 if (get_bubblelevel(adev))
741 adev->bubble_level->poll_once(adev->bubble_level);
749 struct audio_device *adev = in->dev;
764 adev->input_source = in->input_source;
765 adev->in_device = in->device;
766 adev->in_channel_mask = in->channel_mask;
769 select_devices(adev);
772 start_bt_sco(adev);
779 if (get_bubblelevel(adev)) {
780 adev->bubble_level->set_poll_interval(adev->bubble_level, BL_POLL_INTERVAL_MIN_SEC);
781 adev->bubble_level->start_polling(adev->bubble_level);
968 struct audio_device *adev = out->dev;
980 if (out == adev->outputs[OUTPUT_HDMI]) {
983 force_non_hdmi_out_standby(adev);
987 stop_bt_sco(adev);
990 adev->out_device = output_devices(out);
993 if (adev->out_device)
994 select_devices(adev);
1024 struct audio_device *adev = out->dev;
1034 pthread_mutex_lock(&adev->lock);
1042 (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
1043 (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) {
1053 if (!out->standby && (out == adev->outputs[OUTPUT_HDMI] ||
1054 !adev->outputs[OUTPUT_HDMI] ||
1055 adev->outputs[OUTPUT_HDMI]->standby)) {
1056 adev->out_device = output_devices(out) | val;
1057 select_devices(adev);
1063 pthread_mutex_unlock(&adev->lock);
1121 struct audio_device *adev = out->dev;
1123 if (out == adev->outputs[OUTPUT_HDMI]) {
1136 struct audio_device *adev = out->dev;
1145 pthread_mutex_lock(&adev->lock);
1150 pthread_mutex_unlock(&adev->lock);
1155 pthread_mutex_unlock(&adev->lock);
1284 struct audio_device *adev = in->dev;
1291 stop_bt_sco(adev);
1296 select_devices(adev);
1299 if (get_bubblelevel(adev))
1300 in->dev->bubble_level->stop_polling(adev->bubble_level);
1331 struct audio_device *adev = in->dev;
1340 pthread_mutex_lock(&adev->lock);
1371 adev->input_source = in->input_source;
1372 adev->in_device = in->device;
1373 select_devices(adev);
1377 pthread_mutex_unlock(&adev->lock);
1426 struct audio_device *adev = in->dev;
1435 pthread_mutex_lock(&adev->lock);
1442 pthread_mutex_unlock(&adev->lock);
1462 if (ret == 0 && adev->mic_mute)
1524 struct audio_device *adev = (struct audio_device *)dev;
1541 pthread_mutex_lock(&adev->lock);
1542 ret = read_hdmi_channel_masks(adev, out);
1543 pthread_mutex_unlock(&adev->lock);
1585 out->dev = adev;
1595 pthread_mutex_lock(&adev->lock);
1596 if (adev->outputs[type]) {
1597 pthread_mutex_unlock(&adev->lock);
1601 adev->outputs[type] = out;
1602 pthread_mutex_unlock(&adev->lock);
1617 struct audio_device *adev;
1621 adev = (struct audio_device *)dev;
1622 pthread_mutex_lock(&adev->lock);
1624 if (adev->outputs[type] == (struct stream_out *) stream) {
1625 adev->outputs[type] = NULL;
1629 pthread_mutex_unlock(&adev->lock);
1641 struct audio_device *adev = (struct audio_device *)dev;
1679 struct audio_device *adev = (struct audio_device *)dev;
1681 adev->mic_mute = state;
1688 struct audio_device *adev = (struct audio_device *)dev;
1690 *state = adev->mic_mute;
1709 struct audio_device *adev = (struct audio_device *)dev;
1742 in->dev = adev;
1806 struct audio_device *adev = (struct audio_device *)device;
1808 audio_route_free(adev->ar);
1812 if (adev->hdmi_drv_fd >= 0)
1813 close(adev->hdmi_drv_fd);
1815 if (adev->bubble_level)
1816 bubble_level_release(adev->bubble_level);
1825 struct audio_device *adev;
1831 adev = calloc(1, sizeof(struct audio_device));
1832 if (!adev)
1835 adev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
1836 adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
1837 adev->hw_device.common.module = (struct hw_module_t *) module;
1838 adev->hw_device.common.close = adev_close;
1840 adev->hw_device.init_check = adev_init_check;
1841 adev->hw_device.set_voice_volume = adev_set_voice_volume;
1842 adev->hw_device.set_master_volume = adev_set_master_volume;
1843 adev->hw_device.set_mode = adev_set_mode;
1844 adev->hw_device.set_mic_mute = adev_set_mic_mute;
1845 adev->hw_device.get_mic_mute = adev_get_mic_mute;
1846 adev->hw_device.set_parameters = adev_set_parameters;
1847 adev->hw_device.get_parameters = adev_get_parameters;
1848 adev->hw_device.get_input_buffer_size = adev_get_input_buffer_size;
1849 adev->hw_device.open_output_stream = adev_open_output_stream;
1850 adev->hw_device.close_output_stream = adev_close_output_stream;
1851 adev->hw_device.open_input_stream = adev_open_input_stream;
1852 adev->hw_device.close_input_stream = adev_close_input_stream;
1853 adev->hw_device.dump = adev_dump;
1855 adev->ar = audio_route_init(MIXER_CARD, NULL);
1856 adev->input_source = AUDIO_SOURCE_DEFAULT;
1857 /* adev->cur_route_id initial value is 0 and such that first device
1860 adev->es305_preset = ES305_PRESET_INIT;
1861 adev->es305_new_mode = ES305_MODE_LEVEL;
1862 adev->es305_mode = ES305_MODE_LEVEL;
1863 adev->hdmi_drv_fd = -1;
1865 *device = &adev->hw_device.common;