Lines Matching refs:handle
197 static void switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t mode);
199 static void disableDevice(alsa_handle_t *handle);
216 int deviceName(alsa_handle_t *handle, unsigned flags, char **value) in deviceName() argument
226 strlcat(ident, handle->useCase, sizeof(ident)); in deviceName()
227 ret = snd_use_case_get(handle->ucMgr, ident, (const char **)value); in deviceName()
262 status_t setHardwareParams(alsa_handle_t *handle) in setHardwareParams() argument
267 unsigned int requestedRate = handle->sampleRate; in setHardwareParams()
269 int channels = handle->channels; in setHardwareParams()
278 reqBuffSize = handle->bufferSize; in setHardwareParams()
280 (int) reqBuffSize, handle->channels, handle->sampleRate); in setHardwareParams()
284 … if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC)) in setHardwareParams()
285 …|| !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC… in setHardwareParams()
286 ALOGV("HWParams: Use 4 channels in kernel for 5.1(%s) recording ", handle->useCase); in setHardwareParams()
295 if (handle->format != SNDRV_PCM_FORMAT_S16_LE) { in setHardwareParams()
296 if (handle->format == AudioSystem::AMR_NB in setHardwareParams()
297 || handle->format == AudioSystem::AMR_WB in setHardwareParams()
299 || handle->format == AudioSystem::EVRC in setHardwareParams()
300 || handle->format == AudioSystem::EVRCB in setHardwareParams()
301 || handle->format == AudioSystem::EVRCWB in setHardwareParams()
316 param_set_int(params, SNDRV_PCM_HW_PARAM_RATE, handle->sampleRate); in setHardwareParams()
317 param_set_hw_refine(handle->handle, params); in setHardwareParams()
319 if (param_set_hw_params(handle->handle, params)) { in setHardwareParams()
325 handle->handle->buffer_size = pcm_buffer_size(params); in setHardwareParams()
326 handle->handle->period_size = pcm_period_size(params); in setHardwareParams()
327 handle->handle->period_cnt = handle->handle->buffer_size/handle->handle->period_size; in setHardwareParams()
329 handle->handle->buffer_size, handle->handle->period_size, in setHardwareParams()
330 handle->handle->period_cnt); in setHardwareParams()
331 handle->handle->rate = handle->sampleRate; in setHardwareParams()
332 handle->handle->channels = handle->channels; in setHardwareParams()
333 handle->periodSize = handle->handle->period_size; in setHardwareParams()
334 if (strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC) && in setHardwareParams()
335 strcmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC) && in setHardwareParams()
336 (6 != handle->channels)) { in setHardwareParams()
338 handle->bufferSize = handle->handle->period_size; in setHardwareParams()
344 status_t setSoftwareParams(alsa_handle_t *handle) in setSoftwareParams() argument
347 struct pcm* pcm = handle->handle; in setSoftwareParams()
350 int channels = handle->channels; in setSoftwareParams()
360 … if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC)) in setSoftwareParams()
361 …|| !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC… in setSoftwareParams()
362 ALOGV("SWParams: Use 4 channels in kernel for 5.1(%s) recording ", handle->useCase); in setSoftwareParams()
371 if(((!strcmp(handle->useCase,SND_USE_CASE_MOD_PLAY_VOIP)) || in setSoftwareParams()
372 (!strcmp(handle->useCase,SND_USE_CASE_VERB_IP_VOICECALL)))){ in setSoftwareParams()
374 params->avail_min = handle->channels - 1 ? periodSize/4 : periodSize/2; in setSoftwareParams()
385 if (param_set_sw_params(handle->handle, params)) { in setSoftwareParams()
392 void switchDevice(alsa_handle_t *handle, uint32_t devices, uint32_t mode) in switchDevice() argument
455 if ((devices & AudioSystem::DEVICE_IN_BUILTIN_MIC) && ( 6 == handle->channels)) { in switchDevice()
456 … if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC)) in switchDevice()
457 …|| !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC… in switchDevice()
458 …OGV(" switchDevice , use ssr devices for channels:%d usecase:%s",handle->channels,handle->useCase); in switchDevice()
489 snd_use_case_get(handle->ucMgr, "_verb", (const char **)&use_case); in switchDevice()
490 mods_size = snd_use_case_get_list(handle->ucMgr, "_enamods", &mods_list); in switchDevice()
500 snd_use_case_set(handle->ucMgr, "_verb", SND_USE_CASE_VERB_INACTIVE); in switchDevice()
510 snd_use_case_set(handle->ucMgr, "_dismod", mods_list[index]); in switchDevice()
515 snd_use_case_set(handle->ucMgr, "_disdev", curRxUCMDevice); in switchDevice()
527 snd_use_case_set(handle->ucMgr, "_verb", SND_USE_CASE_VERB_INACTIVE); in switchDevice()
537 snd_use_case_set(handle->ucMgr, "_dismod", mods_list[index]); in switchDevice()
542 snd_use_case_set(handle->ucMgr, "_disdev", curTxUCMDevice); in switchDevice()
548 snd_use_case_set(handle->ucMgr, "_enadev", rxDevice); in switchDevice()
556 snd_use_case_set(handle->ucMgr, "_enadev", txDevice); in switchDevice()
563 snd_use_case_set(handle->ucMgr, "_verb", it->useCase); in switchDevice()
565 snd_use_case_set(handle->ucMgr, "_enamod", it->useCase); in switchDevice()
581 tx_dev_id = snd_use_case_get(handle->ucMgr, ident, NULL); in switchDevice()
587 rx_dev_id = snd_use_case_get(handle->ucMgr, ident, NULL); in switchDevice()
629 static status_t s_open(alsa_handle_t *handle) in s_open() argument
635 if(handle->devices & AudioSystem::DEVICE_OUT_AUX_DIGITAL) { in s_open()
643 …if((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) || (!strcmp(handle->useCase, SND_U… in s_open()
644 …||(!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) || (!strcmp(handle->useCase, SND_USE_C… in s_open()
649 s_close(handle); in s_open()
651 ALOGV("s_open: handle %p", handle); in s_open()
659 if ((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) || in s_open()
660 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA)) || in s_open()
661 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) || in s_open()
662 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))) { in s_open()
666 } else if ((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI)) || in s_open()
667 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI2)) || in s_open()
668 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOWLATENCY_MUSIC)) || in s_open()
669 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC)) || in s_open()
670 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_MUSIC2)) || in s_open()
671 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_MUSIC))) { in s_open()
677 if (handle->channels == 1) { in s_open()
680 else if (handle->channels == 4 ) { in s_open()
682 } else if (handle->channels == 6 ) { in s_open()
684 … if (!strncmp(handle->useCase, SND_USE_CASE_VERB_HIFI_REC, strlen(SND_USE_CASE_VERB_HIFI_REC)) in s_open()
685 …|| !strncmp(handle->useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC, strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC… in s_open()
697 if (deviceName(handle, flags, &devName) < 0) { in s_open()
702 handle->handle = pcm_open(flags, (char*)devName); in s_open()
708 if (!handle->handle) { in s_open()
714 handle->handle->flags = flags; in s_open()
715 err = setHardwareParams(handle); in s_open()
718 err = setSoftwareParams(handle); in s_open()
723 s_standby(handle); in s_open()
730 static status_t s_start_voip_call(alsa_handle_t *handle) in s_start_voip_call() argument
739 s_close(handle); in s_start_voip_call()
742 ALOGV("s_open:s_start_voip_call handle %p", handle); in s_start_voip_call()
744 if (deviceName(handle, flags, &devName) < 0) { in s_start_voip_call()
750 handle->handle = pcm_open(flags, (char*)devName); in s_start_voip_call()
756 if (!handle->handle) { in s_start_voip_call()
762 if (!pcm_ready(handle->handle)) { in s_start_voip_call()
766 handle->handle->flags = flags; in s_start_voip_call()
767 err = setHardwareParams(handle); in s_start_voip_call()
770 err = setSoftwareParams(handle); in s_start_voip_call()
773 err = pcm_prepare(handle->handle); in s_start_voip_call()
780 pcm_write(handle->handle,&voc_pkt,handle->handle->period_size); in s_start_voip_call()
781 handle->rxHandle = handle->handle; in s_start_voip_call()
786 handle->handle = 0; in s_start_voip_call()
788 if (deviceName(handle, flags, &devName1) < 0) { in s_start_voip_call()
793 handle->handle = pcm_open(flags, (char*)devName1); in s_start_voip_call()
799 if (!handle->handle) { in s_start_voip_call()
805 if (!pcm_ready(handle->handle)) { in s_start_voip_call()
809 handle->handle->flags = flags; in s_start_voip_call()
811 err = setHardwareParams(handle); in s_start_voip_call()
814 err = setSoftwareParams(handle); in s_start_voip_call()
818 err = pcm_prepare(handle->handle); in s_start_voip_call()
825 pcm_read(handle->handle,&voc_pkt,handle->handle->period_size); in s_start_voip_call()
829 static status_t s_start_voice_call(alsa_handle_t *handle) in s_start_voice_call() argument
835 ALOGV("s_start_voice_call: handle %p", handle); in s_start_voice_call()
841 if (deviceName(handle, flags, &devName) < 0) { in s_start_voice_call()
846 handle->handle = pcm_open(flags, (char*)devName); in s_start_voice_call()
851 if (!handle->handle) { in s_start_voice_call()
856 handle->handle->flags = flags; in s_start_voice_call()
857 err = setHardwareParams(handle); in s_start_voice_call()
863 err = setSoftwareParams(handle); in s_start_voice_call()
869 err = pcm_prepare(handle->handle); in s_start_voice_call()
875 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) { in s_start_voice_call()
881 handle->rxHandle = handle->handle; in s_start_voice_call()
886 if (deviceName(handle, flags, &devName) < 0) { in s_start_voice_call()
891 handle->handle = pcm_open(flags, (char*)devName); in s_start_voice_call()
896 if (!handle->handle) { in s_start_voice_call()
901 handle->handle->flags = flags; in s_start_voice_call()
902 err = setHardwareParams(handle); in s_start_voice_call()
908 err = setSoftwareParams(handle); in s_start_voice_call()
914 err = pcm_prepare(handle->handle); in s_start_voice_call()
920 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) { in s_start_voice_call()
945 s_close(handle); in s_start_voice_call()
949 static status_t s_start_fm(alsa_handle_t *handle) in s_start_fm() argument
955 ALOGV("s_start_fm: handle %p", handle); in s_start_fm()
961 if (deviceName(handle, flags, &devName) < 0) { in s_start_fm()
966 handle->handle = pcm_open(flags, (char*)devName); in s_start_fm()
971 if (!handle->handle) { in s_start_fm()
976 handle->handle->flags = flags; in s_start_fm()
977 err = setHardwareParams(handle); in s_start_fm()
983 err = setSoftwareParams(handle); in s_start_fm()
989 err = pcm_prepare(handle->handle); in s_start_fm()
995 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) { in s_start_fm()
1001 handle->rxHandle = handle->handle; in s_start_fm()
1006 if (deviceName(handle, flags, &devName) < 0) { in s_start_fm()
1011 handle->handle = pcm_open(flags, (char*)devName); in s_start_fm()
1016 if (!handle->handle) { in s_start_fm()
1020 handle->handle->flags = flags; in s_start_fm()
1021 err = setHardwareParams(handle); in s_start_fm()
1027 err = setSoftwareParams(handle); in s_start_fm()
1033 err = pcm_prepare(handle->handle); in s_start_fm()
1039 if (ioctl(handle->handle->fd, SNDRV_PCM_IOCTL_START)) { in s_start_fm()
1050 s_close(handle); in s_start_fm()
1075 static status_t s_start(alsa_handle_t *handle) in s_start() argument
1079 if(!handle->handle) { in s_start()
1084 err = pcm_prepare(handle->handle); in s_start()
1089 static status_t s_close(alsa_handle_t *handle) in s_close() argument
1093 struct pcm *h = handle->rxHandle; in s_close()
1095 handle->rxHandle = 0; in s_close()
1096 ALOGV("s_close: handle %p h %p", handle, h); in s_close()
1098 if ((!strcmp(handle->useCase, SND_USE_CASE_VERB_VOICECALL) || in s_close()
1099 !strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_VOICE)) && in s_close()
1120 h = handle->handle; in s_close()
1121 handle->handle = 0; in s_close()
1130 disableDevice(handle); in s_close()
1131 } else if((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) || in s_close()
1132 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA)) || in s_close()
1133 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) || in s_close()
1134 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))){ in s_close()
1135 disableDevice(handle); in s_close()
1147 static status_t s_standby(alsa_handle_t *handle) in s_standby() argument
1151 struct pcm *h = handle->rxHandle; in s_standby()
1152 handle->rxHandle = 0; in s_standby()
1153 ALOGV("s_standby: handle %p h %p", handle, h); in s_standby()
1162 h = handle->handle; in s_standby()
1163 handle->handle = 0; in s_standby()
1171 disableDevice(handle); in s_standby()
1172 } else if((!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER)) || in s_standby()
1173 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_LPA)) || in s_standby()
1174 (!strcmp(handle->useCase, SND_USE_CASE_VERB_HIFI_TUNNEL)) || in s_standby()
1175 (!strcmp(handle->useCase, SND_USE_CASE_MOD_PLAY_TUNNEL))) { in s_standby()
1176 disableDevice(handle); in s_standby()
1182 static status_t s_route(alsa_handle_t *handle, uint32_t devices, int mode) in s_route() argument
1188 switchDevice(handle, devices, mode); in s_route()
1272 static void disableDevice(alsa_handle_t *handle) in disableDevice() argument
1279 snd_use_case_get(handle->ucMgr, "_verb", (const char **)&useCase); in disableDevice()
1281 if (!strncmp(useCase, handle->useCase, MAX_UC_LEN)) { in disableDevice()
1282 snd_use_case_set(handle->ucMgr, "_verb", SND_USE_CASE_VERB_INACTIVE); in disableDevice()
1284 snd_use_case_set(handle->ucMgr, "_dismod", handle->useCase); in disableDevice()
1287 snd_use_case_get(handle->ucMgr, "_verb", (const char **)&useCase); in disableDevice()
1291 mods_size = snd_use_case_get_list(handle->ucMgr, "_enamods", &mods_list); in disableDevice()
1301 snd_use_case_set(handle->ucMgr, "_disdev", curTxUCMDevice); in disableDevice()
1303 snd_use_case_set(handle->ucMgr, "_disdev", curRxUCMDevice); in disableDevice()
1789 static void s_set_csd_handle(void* handle) in getUCMDevice()
1791 csd_handle = static_cast<void*>(handle); in getUCMDevice()