Lines Matching refs:handle

106     void (*thermal_client_unregister_callback)(int handle);
124 static struct speaker_prot_session handle; variable
131 handle.spkr_in_use = true; in spkr_prot_set_spkrstatus()
133 handle.spkr_in_use = false; in spkr_prot_set_spkrstatus()
134 clock_gettime(CLOCK_BOOTTIME, &handle.spkr_last_time_used); in spkr_prot_set_spkrstatus()
145 if (pthread_equal(handle.speaker_prot_threadid, threadid) || !adev) { in audio_extn_spkr_prot_calib_cancel()
151 pthread_mutex_lock(&handle.mutex_spkr_prot); in audio_extn_spkr_prot_calib_cancel()
152 pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex); in audio_extn_spkr_prot_calib_cancel()
153 handle.cancel_spkr_calib = 1; in audio_extn_spkr_prot_calib_cancel()
154 pthread_cond_signal(&handle.spkr_calib_cancel); in audio_extn_spkr_prot_calib_cancel()
155 pthread_mutex_unlock(&handle.mutex_spkr_prot); in audio_extn_spkr_prot_calib_cancel()
156 pthread_cond_wait(&handle.spkr_calibcancel_ack, in audio_extn_spkr_prot_calib_cancel()
157 &handle.spkr_calib_cancelack_mutex); in audio_extn_spkr_prot_calib_cancel()
158 pthread_mutex_unlock(&handle.spkr_calib_cancelack_mutex); in audio_extn_spkr_prot_calib_cancel()
170 if (handle.spkr_in_use) { in is_speaker_in_use()
175 *sec = temp.tv_sec - handle.spkr_last_time_used.tv_sec; in is_speaker_in_use()
298 struct audio_device *adev = handle.adev_handle; in spkr_calibrate()
354 handle.pcm_rx = handle.pcm_tx = NULL; in spkr_calibrate()
355 handle.pcm_rx = pcm_open(adev->snd_card, in spkr_calibrate()
358 if (handle.pcm_rx && !pcm_is_ready(handle.pcm_rx)) { in spkr_calibrate()
359 ALOGE("%s: %s", __func__, pcm_get_error(handle.pcm_rx)); in spkr_calibrate()
386 handle.pcm_tx = pcm_open(adev->snd_card, in spkr_calibrate()
389 if (handle.pcm_tx && !pcm_is_ready(handle.pcm_tx)) { in spkr_calibrate()
390 ALOGE("%s: %s", __func__, pcm_get_error(handle.pcm_tx)); in spkr_calibrate()
394 if (pcm_start(handle.pcm_rx) < 0) { in spkr_calibrate()
399 if (pcm_start(handle.pcm_tx) < 0) { in spkr_calibrate()
408 pthread_mutex_lock(&handle.mutex_spkr_prot); in spkr_calibrate()
411 (void)pthread_cond_timedwait(&handle.spkr_calib_cancel, in spkr_calibrate()
412 &handle.mutex_spkr_prot, &ts); in spkr_calibrate()
414 pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex); in spkr_calibrate()
415 if (handle.cancel_spkr_calib) { in spkr_calibrate()
466 if (handle.pcm_rx) in spkr_calibrate()
467 pcm_close(handle.pcm_rx); in spkr_calibrate()
468 handle.pcm_rx = NULL; in spkr_calibrate()
470 if (handle.pcm_tx) in spkr_calibrate()
471 pcm_close(handle.pcm_tx); in spkr_calibrate()
472 handle.pcm_tx = NULL; in spkr_calibrate()
483 handle.spkr_prot_mode = MSM_SPKR_PROT_CALIBRATED; in spkr_calibrate()
486 handle.spkr_prot_mode = MSM_SPKR_PROT_NOT_CALIBRATED; in spkr_calibrate()
493 if (!handle.cancel_spkr_calib && cleanup) { in spkr_calibrate()
494 pthread_mutex_unlock(&handle.spkr_calib_cancelack_mutex); in spkr_calibrate()
495 pthread_cond_wait(&handle.spkr_calib_cancel, &handle.mutex_spkr_prot); in spkr_calibrate()
496 pthread_mutex_lock(&handle.spkr_calib_cancelack_mutex); in spkr_calibrate()
511 if (handle.cancel_spkr_calib) in spkr_calibrate()
512 pthread_cond_signal(&handle.spkr_calibcancel_ack); in spkr_calibrate()
513 handle.cancel_spkr_calib = 0; in spkr_calibrate()
514 pthread_mutex_unlock(&handle.spkr_calib_cancelack_mutex); in spkr_calibrate()
515 pthread_mutex_unlock(&handle.mutex_spkr_prot); in spkr_calibrate()
530 struct audio_device *adev = handle.adev_handle; in spkr_calibration_thread()
542 handle.speaker_prot_threadid = pthread_self(); in spkr_calibration_thread()
550 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED; in spkr_calibration_thread()
553 handle.spkr_prot_mode = MSM_SPKR_PROT_NOT_CALIBRATED; in spkr_calibration_thread()
555 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED; in spkr_calibration_thread()
558 if (handle.spkr_prot_mode == MSM_SPKR_PROT_DISABLED) { in spkr_calibration_thread()
600 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED; in spkr_calibration_thread()
602 handle.spkr_prot_mode = MSM_SPKR_PROT_CALIBRATED; in spkr_calibration_thread()
612 if (!handle.thermal_client_request("spkr",1)) { in spkr_calibration_thread()
614 pthread_mutex_lock(&handle.spkr_prot_thermalsync_mutex); in spkr_calibration_thread()
615 pthread_cond_wait(&handle.spkr_prot_thermalsync, in spkr_calibration_thread()
616 &handle.spkr_prot_thermalsync_mutex); in spkr_calibration_thread()
618 t0 = (handle.spkr_prot_t0 * (1 << 6)); in spkr_calibration_thread()
619 pthread_mutex_unlock(&handle.spkr_prot_thermalsync_mutex); in spkr_calibration_thread()
622 handle.spkr_prot_t0); in spkr_calibration_thread()
626 handle.spkr_prot_t0); in spkr_calibration_thread()
667 if (handle.thermal_client_handle) in spkr_calibration_thread()
668 handle.thermal_client_unregister_callback(handle.thermal_client_handle); in spkr_calibration_thread()
669 handle.thermal_client_handle = 0; in spkr_calibration_thread()
670 if (handle.thermal_handle) in spkr_calibration_thread()
671 dlclose(handle.thermal_handle); in spkr_calibration_thread()
672 handle.thermal_handle = NULL; in spkr_calibration_thread()
679 pthread_mutex_lock(&handle.spkr_prot_thermalsync_mutex); in thermal_client_callback()
681 if (handle.spkr_prot_mode == MSM_SPKR_PROT_NOT_CALIBRATED) in thermal_client_callback()
682 handle.spkr_prot_t0 = temp; in thermal_client_callback()
683 pthread_cond_signal(&handle.spkr_prot_thermalsync); in thermal_client_callback()
684 pthread_mutex_unlock(&handle.spkr_prot_thermalsync_mutex); in thermal_client_callback()
692 memset(&handle, 0, sizeof(handle)); in audio_extn_spkr_prot_init()
698 handle.spkr_prot_enable = false; in audio_extn_spkr_prot_init()
700 handle.spkr_prot_enable = true; in audio_extn_spkr_prot_init()
701 if (!handle.spkr_prot_enable) { in audio_extn_spkr_prot_init()
705 handle.adev_handle = adev; in audio_extn_spkr_prot_init()
706 handle.spkr_prot_mode = MSM_SPKR_PROT_DISABLED; in audio_extn_spkr_prot_init()
707 handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE; in audio_extn_spkr_prot_init()
708 handle.spkr_prot_t0 = -1; in audio_extn_spkr_prot_init()
709 pthread_cond_init(&handle.spkr_prot_thermalsync, NULL); in audio_extn_spkr_prot_init()
710 pthread_cond_init(&handle.spkr_calib_cancel, NULL); in audio_extn_spkr_prot_init()
711 pthread_cond_init(&handle.spkr_calibcancel_ack, NULL); in audio_extn_spkr_prot_init()
712 pthread_mutex_init(&handle.mutex_spkr_prot, NULL); in audio_extn_spkr_prot_init()
713 pthread_mutex_init(&handle.spkr_calib_cancelack_mutex, NULL); in audio_extn_spkr_prot_init()
714 pthread_mutex_init(&handle.spkr_prot_thermalsync_mutex, NULL); in audio_extn_spkr_prot_init()
715 handle.thermal_handle = dlopen(THERMAL_CLIENT_LIBRARY_PATH, in audio_extn_spkr_prot_init()
717 if (!handle.thermal_handle) { in audio_extn_spkr_prot_init()
721 handle.thermal_client_register_callback = in audio_extn_spkr_prot_init()
723 dlsym(handle.thermal_handle, "thermal_client_register_callback"); in audio_extn_spkr_prot_init()
724 handle.thermal_client_unregister_callback = in audio_extn_spkr_prot_init()
726 dlsym(handle.thermal_handle, "thermal_client_unregister_callback"); in audio_extn_spkr_prot_init()
727 if (!handle.thermal_client_register_callback || in audio_extn_spkr_prot_init()
728 !handle.thermal_client_unregister_callback) { in audio_extn_spkr_prot_init()
732 handle.thermal_client_handle = in audio_extn_spkr_prot_init()
733 handle.thermal_client_register_callback("spkr", thermal_client_callback, NULL); in audio_extn_spkr_prot_init()
734 if (!handle.thermal_client_handle) { in audio_extn_spkr_prot_init()
738 handle.thermal_client_request = (int (*)(char *, int)) in audio_extn_spkr_prot_init()
739 dlsym(handle.thermal_handle, "thermal_client_request"); in audio_extn_spkr_prot_init()
743 if (handle.thermal_client_request) { in audio_extn_spkr_prot_init()
745 (void)pthread_create(&handle.spkr_calibration_thread, in audio_extn_spkr_prot_init()
746 (const pthread_attr_t *) NULL, spkr_calibration_thread, &handle); in audio_extn_spkr_prot_init()
749 if (handle.thermal_client_handle && in audio_extn_spkr_prot_init()
750 handle.thermal_client_unregister_callback) in audio_extn_spkr_prot_init()
751 handle.thermal_client_unregister_callback(handle.thermal_client_handle); in audio_extn_spkr_prot_init()
752 if (handle.thermal_handle) in audio_extn_spkr_prot_init()
753 dlclose(handle.thermal_handle); in audio_extn_spkr_prot_init()
754 handle.thermal_handle = NULL; in audio_extn_spkr_prot_init()
755 handle.spkr_prot_enable = false; in audio_extn_spkr_prot_init()
758 if (handle.spkr_prot_enable) { in audio_extn_spkr_prot_init()
789 if (!handle.spkr_prot_enable) in audio_extn_get_spkr_prot_snd_device()
805 struct audio_device *adev = handle.adev_handle; in audio_extn_spkr_prot_start_processing()
824 pthread_mutex_lock(&handle.mutex_spkr_prot); in audio_extn_spkr_prot_start_processing()
825 if (handle.spkr_processing_state == SPKR_PROCESSING_IN_IDLE) { in audio_extn_spkr_prot_start_processing()
830 handle.pcm_tx = NULL; in audio_extn_spkr_prot_start_processing()
842 handle.pcm_tx = pcm_open(adev->snd_card, in audio_extn_spkr_prot_start_processing()
845 if (handle.pcm_tx && !pcm_is_ready(handle.pcm_tx)) { in audio_extn_spkr_prot_start_processing()
846 ALOGE("%s: %s", __func__, pcm_get_error(handle.pcm_tx)); in audio_extn_spkr_prot_start_processing()
850 if (pcm_start(handle.pcm_tx) < 0) { in audio_extn_spkr_prot_start_processing()
860 if (handle.pcm_tx) in audio_extn_spkr_prot_start_processing()
861 pcm_close(handle.pcm_tx); in audio_extn_spkr_prot_start_processing()
862 handle.pcm_tx = NULL; in audio_extn_spkr_prot_start_processing()
868 handle.spkr_processing_state = SPKR_PROCESSING_IN_PROGRESS; in audio_extn_spkr_prot_start_processing()
869 pthread_mutex_unlock(&handle.mutex_spkr_prot); in audio_extn_spkr_prot_start_processing()
877 struct audio_device *adev = handle.adev_handle; in audio_extn_spkr_prot_stop_processing()
882 pthread_mutex_lock(&handle.mutex_spkr_prot); in audio_extn_spkr_prot_stop_processing()
883 if (adev && handle.spkr_processing_state == SPKR_PROCESSING_IN_PROGRESS) { in audio_extn_spkr_prot_stop_processing()
885 if (handle.pcm_tx) in audio_extn_spkr_prot_stop_processing()
886 pcm_close(handle.pcm_tx); in audio_extn_spkr_prot_stop_processing()
887 handle.pcm_tx = NULL; in audio_extn_spkr_prot_stop_processing()
895 handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE; in audio_extn_spkr_prot_stop_processing()
896 pthread_mutex_unlock(&handle.mutex_spkr_prot); in audio_extn_spkr_prot_stop_processing()
905 return handle.spkr_prot_enable; in audio_extn_spkr_prot_is_enabled()