├── visualizer ├── MODULE_LICENSE_APACHE2 ├── Android.mk └── NOTICE ├── legacy ├── alsa_sound │ ├── MODULE_LICENSE_APACHE2 │ ├── AudioPolicyManagerALSA.h │ ├── AudioUtil.h │ ├── CleanSpec.mk │ ├── acoustics_default.cpp │ ├── ALSAControl.cpp │ ├── Android.mk │ ├── AudioUsbALSA.h │ ├── AudioPolicyManagerALSA.cpp │ └── AudioUtil.cpp ├── Android.mk └── libalsa-intf │ ├── Makefile.am │ ├── Android.mk │ ├── amix.c │ ├── alsa_audio.h │ └── alsaucm_test.c ├── METADATA ├── OWNERS ├── Android.mk ├── voice_processing └── Android.mk ├── hal ├── audio_perf.h ├── audio_extn │ ├── audiozoom.h │ ├── maxxaudio.h │ ├── tfa_98xx.h │ ├── dsm_feedback.c │ ├── hwdep_cal.c │ ├── ext_speaker.c │ ├── audio_extn.c │ └── audiozoom.c ├── acdb.h ├── voice.h ├── voice_extn │ └── voice_extn.h ├── msm8916 │ ├── hw_info.c │ └── platform.h ├── msm8974 │ └── hw_info.c ├── msm8960 │ └── platform.h ├── acdb.c ├── Android.mk └── audio_perf.cpp └── post_proc ├── bass_boost.h ├── virtualizer.h ├── equalizer.h ├── reverb.h ├── Android.mk ├── bundle.h ├── effect_api.h ├── bass_boost.c └── virtualizer.c /visualizer/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /legacy/alsa_sound/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /METADATA: -------------------------------------------------------------------------------- 1 | third_party { 2 | # would be NOTICE save for legacy/libalsa-intf/alsa_ucm.h 3 | license_type: RESTRICTED 4 | } 5 | -------------------------------------------------------------------------------- /legacy/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter msm8960,$(TARGET_BOARD_PLATFORM)),) 2 | 3 | include $(call all-subdir-makefiles) 4 | 5 | endif 6 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # Default code reviewers picked from top 3 or more developers. 2 | # Please update this list if you find better candidates. 3 | hunga@google.com 4 | krocard@google.com 5 | elaurent@google.com 6 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # TODO: Find a better way to separate build configs for ADP vs non-ADP devices 2 | ifneq ($(TARGET_BOARD_AUTO),true) 3 | ifneq ($(filter msm8960 msm8226 msm8x26 msm8x84 msm8084 msm8992 msm8994 msm8996 msm8909 msm8952 msm8998 sdm845 sdm710,$(TARGET_BOARD_PLATFORM)),) 4 | 5 | MY_LOCAL_PATH := $(call my-dir) 6 | 7 | ifeq ($(BOARD_USES_LEGACY_ALSA_AUDIO),true) 8 | include $(MY_LOCAL_PATH)/legacy/Android.mk 9 | else 10 | include $(MY_LOCAL_PATH)/hal/Android.mk 11 | include $(MY_LOCAL_PATH)/voice_processing/Android.mk 12 | include $(MY_LOCAL_PATH)/visualizer/Android.mk 13 | include $(MY_LOCAL_PATH)/post_proc/Android.mk 14 | endif 15 | endif 16 | endif 17 | -------------------------------------------------------------------------------- /voice_processing/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | # audio preprocessing wrapper 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_MODULE:= libqcomvoiceprocessing 7 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 8 | LOCAL_LICENSE_CONDITIONS:= notice 9 | LOCAL_MODULE_TAGS := optional 10 | LOCAL_MODULE_OWNER := qcom 11 | LOCAL_PROPRIETARY_MODULE := true 12 | LOCAL_MODULE_RELATIVE_PATH := soundfx 13 | 14 | LOCAL_SRC_FILES:= \ 15 | voice_processing.c 16 | 17 | LOCAL_CFLAGS += \ 18 | -Wall \ 19 | -Werror \ 20 | -Wno-unused-function \ 21 | -Wno-unused-variable \ 22 | 23 | LOCAL_C_INCLUDES += \ 24 | $(call include-path-for, audio-effects) 25 | 26 | LOCAL_SHARED_LIBRARIES := \ 27 | liblog \ 28 | libcutils 29 | 30 | LOCAL_SHARED_LIBRARIES += libdl 31 | 32 | LOCAL_CFLAGS += -fvisibility=hidden 33 | 34 | LOCAL_HEADER_LIBRARIES += libhardware_headers 35 | include $(BUILD_SHARED_LIBRARY) 36 | -------------------------------------------------------------------------------- /hal/audio_perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __QAUDIOPERF_H__ 18 | #define __QAUDIOPERF_H__ 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | // return true on success, false on failure 27 | bool audio_streaming_hint_start(); 28 | bool audio_streaming_hint_end(); 29 | bool audio_low_latency_hint_start(); 30 | bool audio_low_latency_hint_end(); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif //__QAUDIOPERF_H__ 37 | -------------------------------------------------------------------------------- /hal/audio_extn/audiozoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef AUDIOZOOM_H_ 18 | #define AUDIOZOOM_H_ 19 | 20 | #ifndef AUDIOZOOM_QDSP_ENABLED 21 | #define audio_extn_audiozoom_init() (0) 22 | #define audio_extn_audiozoom_set_microphone_direction(stream, dir) (-ENOSYS) 23 | #define audio_extn_audiozoom_set_microphone_field_dimension(stream, zoom) (-ENOSYS) 24 | #else 25 | int audio_extn_audiozoom_init(); 26 | int audio_extn_audiozoom_set_microphone_direction(struct stream_in *stream, 27 | audio_microphone_direction_t dir); 28 | int audio_extn_audiozoom_set_microphone_field_dimension(struct stream_in *stream, float zoom); 29 | #endif 30 | 31 | #endif /* AUDIOZOOM_H_ */ 32 | -------------------------------------------------------------------------------- /legacy/alsa_sound/AudioPolicyManagerALSA.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * Copyright (C) 2011-2012, Code Aurora Forum. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | namespace android_audio_legacy { 28 | 29 | // ---------------------------------------------------------------------------- 30 | 31 | class AudioPolicyManager: public AudioPolicyManagerBase 32 | { 33 | 34 | public: 35 | AudioPolicyManager(AudioPolicyClientInterface *clientInterface) 36 | : AudioPolicyManagerBase(clientInterface) {} 37 | 38 | virtual void setPhoneState(int state); 39 | 40 | virtual ~AudioPolicyManager() {} 41 | 42 | }; 43 | }; 44 | -------------------------------------------------------------------------------- /visualizer/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_SRC_FILES:= \ 20 | offload_visualizer.c 21 | 22 | LOCAL_CFLAGS+= -O2 -fvisibility=hidden 23 | 24 | LOCAL_SHARED_LIBRARIES := \ 25 | libcutils \ 26 | liblog \ 27 | libdl \ 28 | libtinyalsa 29 | 30 | LOCAL_CFLAGS += \ 31 | -Wall \ 32 | -Werror \ 33 | -Wno-unused-variable \ 34 | 35 | LOCAL_HEADER_LIBRARIES := libhardware_headers 36 | 37 | LOCAL_MODULE_RELATIVE_PATH := soundfx 38 | LOCAL_MODULE:= libqcomvisualizer 39 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 40 | LOCAL_LICENSE_CONDITIONS:= notice 41 | LOCAL_NOTICE_FILE:= $(LOCAL_PATH)/NOTICE 42 | LOCAL_MODULE_OWNER := qcom 43 | LOCAL_PROPRIETARY_MODULE := true 44 | 45 | LOCAL_C_INCLUDES := \ 46 | external/tinyalsa/include \ 47 | $(call include-path-for, audio-effects) 48 | 49 | LOCAL_HEADER_LIBRARIES += libsystem_headers 50 | include $(BUILD_SHARED_LIBRARY) 51 | -------------------------------------------------------------------------------- /legacy/libalsa-intf/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = -Wundef \ 2 | -Wstrict-prototypes \ 3 | -Wno-trigraphs \ 4 | -g -O0 \ 5 | -fno-inline \ 6 | -fno-short-enums \ 7 | -fpic \ 8 | -DQC_PROP 9 | 10 | AM_CPPFLAGS = -I. \ 11 | $(ACDBLOADER_CFLAGS) 12 | 13 | c_sources = alsa_mixer.c \ 14 | alsa_pcm.c \ 15 | alsa_ucm.c 16 | 17 | h_sources = alsa_ucm.h \ 18 | msm8960_use_cases.h \ 19 | alsa_audio.h 20 | 21 | library_includedir = $(pkgincludedir) 22 | library_include_HEADERS = $(h_sources) 23 | 24 | lib_LTLIBRARIES = libalsa_intf.la 25 | libalsa_intf_la_CC = @CC@ 26 | libalsa_intf_la_SOURCES = $(c_sources) $(h_sources) 27 | libalsa_intfdir = $(prefix)/snd_soc_msm 28 | dist_libalsa_intf_DATA = snd_soc_msm/snd_soc_msm \ 29 | snd_soc_msm/snd_soc_msm_2x \ 30 | snd_soc_msm/snd_soc_msm_2x_Fusion3 \ 31 | snd_soc_msm/snd_soc_msm_Sitar 32 | libalsa_intf_la_CFLAGS = $(AM_CFLAGS) -DUSE_GLIB @GLIB_CFLAGS@ -DCONFIG_DIR=\"/etc/snd_soc_msm/\" 33 | libalsa_intf_la_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_GLIB @GLIB_CFLAGS@ 34 | libalsa_intf_la_LDFLAGS = $(ACDBLOADER_LIBS) -lm -lpthread @GLIB_LIBS@ -shared -version-info 1:0:0 35 | 36 | requiredlibs = libalsa_intf.la 37 | 38 | bin_PROGRAMS = aplay amix arec 39 | 40 | aplay_SOURCES = aplay.c 41 | aplay_LDADD = -lpthread $(requiredlibs) 42 | 43 | amix_SOURCES = amix.c 44 | amix_LDADD = -lpthread $(requiredlibs) 45 | 46 | arec_SOURCES = arec.c 47 | arec_LDADD = -lpthread $(requiredlibs) 48 | -------------------------------------------------------------------------------- /hal/audio_extn/maxxaudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef MAXXAUDIO_H_ 18 | #define MAXXAUDIO_H_ 19 | 20 | #ifndef MAXXAUDIO_QDSP_ENABLED 21 | #define audio_extn_ma_init(platform) (0) 22 | #define audio_extn_ma_deinit() (0) 23 | #define audio_extn_ma_set_state(adev, type, vol, active) (false) 24 | #define audio_extn_ma_set_device(usecase) (0) 25 | #define audio_extn_ma_set_parameters(adev, param) (0) 26 | #define audio_extn_ma_supported_usb() (false) 27 | #else 28 | void audio_extn_ma_init(void *platform); 29 | void audio_extn_ma_deinit(); 30 | bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, 31 | float vol, bool active); 32 | void audio_extn_ma_set_device(struct audio_usecase *usecase); 33 | void audio_extn_ma_set_parameters(struct audio_device *adev, 34 | struct str_parms *parms); 35 | bool audio_extn_ma_supported_usb(); 36 | #endif /* MAXXAUDIO_QDSP_ENABLED */ 37 | 38 | #endif /* MAXXAUDIO_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /hal/audio_extn/tfa_98xx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef TFA_98XX_H 18 | #define TFA_98XX_H 19 | 20 | #ifdef SMART_PA_TFA_98XX_SUPPORTED 21 | int audio_extn_tfa_98xx_enable_speaker(void); 22 | void audio_extn_tfa_98xx_disable_speaker(snd_device_t snd_device); 23 | void audio_extn_tfa_98xx_set_mode(); 24 | void audio_extn_tfa_98xx_set_mode_bt(void); 25 | void audio_extn_tfa_98xx_update(void); 26 | void audio_extn_tfa_98xx_set_voice_vol(float vol); 27 | int audio_extn_tfa_98xx_init(struct audio_device *adev); 28 | void audio_extn_tfa_98xx_deinit(void); 29 | bool audio_extn_tfa_98xx_is_supported(void); 30 | #else 31 | #define audio_extn_tfa_98xx_enable_speaker(void) (0) 32 | #define audio_extn_tfa_98xx_disable_speaker(snd_device) (0) 33 | #define audio_extn_tfa_98xx_set_mode() (0) 34 | #define audio_extn_tfa_98xx_set_mode_bt() (0) 35 | #define audio_extn_tfa_98xx_update(void) (0) 36 | #define audio_extn_tfa_98xx_set_voice_vol(vol) (0) 37 | #define audio_extn_tfa_98xx_init(adev) (0) 38 | #define audio_extn_tfa_98xx_deinit(void) (0) 39 | #define audio_extn_tfa_98xx_is_supported(void) (false) 40 | #endif 41 | 42 | #endif /* TFA_98XX_H */ 43 | -------------------------------------------------------------------------------- /post_proc/bass_boost.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFFLOAD_EFFECT_BASS_BOOST_H_ 18 | #define OFFLOAD_EFFECT_BASS_BOOST_H_ 19 | 20 | #include "bundle.h" 21 | 22 | extern const effect_descriptor_t bassboost_descriptor; 23 | 24 | typedef struct bassboost_context_s { 25 | effect_context_t common; 26 | 27 | int strength; 28 | 29 | // Offload vars 30 | struct mixer_ctl *ctl; 31 | bool temp_disabled; 32 | uint32_t device; 33 | struct bass_boost_params offload_bass; 34 | } bassboost_context_t; 35 | 36 | int bassboost_get_parameter(effect_context_t *context, effect_param_t *p, 37 | uint32_t *size); 38 | 39 | int bassboost_set_parameter(effect_context_t *context, effect_param_t *p, 40 | uint32_t size); 41 | 42 | int bassboost_set_device(effect_context_t *context, uint32_t device); 43 | 44 | int bassboost_reset(effect_context_t *context); 45 | 46 | int bassboost_init(effect_context_t *context); 47 | 48 | int bassboost_enable(effect_context_t *context); 49 | 50 | int bassboost_disable(effect_context_t *context); 51 | 52 | int bassboost_start(effect_context_t *context, output_context_t *output); 53 | 54 | int bassboost_stop(effect_context_t *context, output_context_t *output); 55 | 56 | #endif /* OFFLOAD_EFFECT_BASS_BOOST_H_ */ 57 | -------------------------------------------------------------------------------- /post_proc/virtualizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFFLOAD_VIRTUALIZER_H_ 18 | #define OFFLOAD_VIRTUALIZER_H_ 19 | 20 | #include "bundle.h" 21 | 22 | extern const effect_descriptor_t virtualizer_descriptor; 23 | 24 | typedef struct virtualizer_context_s { 25 | effect_context_t common; 26 | 27 | int strength; 28 | 29 | // Offload vars 30 | struct mixer_ctl *ctl; 31 | bool temp_disabled; 32 | uint32_t device; 33 | struct virtualizer_params offload_virt; 34 | } virtualizer_context_t; 35 | 36 | int virtualizer_get_parameter(effect_context_t *context, effect_param_t *p, 37 | uint32_t *size); 38 | 39 | int virtualizer_set_parameter(effect_context_t *context, effect_param_t *p, 40 | uint32_t size); 41 | 42 | int virtualizer_set_device(effect_context_t *context, uint32_t device); 43 | 44 | int virtualizer_reset(effect_context_t *context); 45 | 46 | int virtualizer_init(effect_context_t *context); 47 | 48 | int virtualizer_enable(effect_context_t *context); 49 | 50 | int virtualizer_disable(effect_context_t *context); 51 | 52 | int virtualizer_start(effect_context_t *context, output_context_t *output); 53 | 54 | int virtualizer_stop(effect_context_t *context, output_context_t *output); 55 | 56 | #endif /* OFFLOAD_VIRTUALIZER_H_ */ 57 | -------------------------------------------------------------------------------- /post_proc/equalizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFFLOAD_EQUALIZER_H_ 18 | #define OFFLOAD_EQUALIZER_H_ 19 | 20 | #include "bundle.h" 21 | 22 | #define NUM_EQ_BANDS 5 23 | #define INVALID_PRESET -2 24 | #define PRESET_CUSTOM -1 25 | 26 | extern const effect_descriptor_t equalizer_descriptor; 27 | 28 | typedef struct equalizer_context_s { 29 | effect_context_t common; 30 | 31 | int preset; 32 | int band_levels[NUM_EQ_BANDS]; 33 | 34 | // Offload vars 35 | struct mixer_ctl *ctl; 36 | uint32_t device; 37 | struct eq_params offload_eq; 38 | } equalizer_context_t; 39 | 40 | int equalizer_get_parameter(effect_context_t *context, effect_param_t *p, 41 | uint32_t *size); 42 | 43 | int equalizer_set_parameter(effect_context_t *context, effect_param_t *p, 44 | uint32_t size); 45 | 46 | int equalizer_set_device(effect_context_t *context, uint32_t device); 47 | 48 | int equalizer_reset(effect_context_t *context); 49 | 50 | int equalizer_init(effect_context_t *context); 51 | 52 | int equalizer_enable(effect_context_t *context); 53 | 54 | int equalizer_disable(effect_context_t *context); 55 | 56 | int equalizer_start(effect_context_t *context, output_context_t *output); 57 | 58 | int equalizer_stop(effect_context_t *context, output_context_t *output); 59 | 60 | #endif /*OFFLOAD_EQUALIZER_H_*/ 61 | -------------------------------------------------------------------------------- /legacy/alsa_sound/AudioUtil.h: -------------------------------------------------------------------------------- 1 | /* AudioUtil.h 2 | * 3 | * Copyright (C) 2012 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef ALSA_SOUND_AUDIO_UTIL_H 19 | #define ALSA_SOUND_AUDIO_UTIL_H 20 | 21 | #define BIT(nr) (1UL << (nr)) 22 | #define MAX_EDID_BLOCKS 10 23 | #define MAX_SHORT_AUDIO_DESC_CNT 30 24 | #define MIN_AUDIO_DESC_LENGTH 3 25 | #define MIN_SPKR_ALLOCATION_DATA_LENGTH 3 26 | 27 | typedef enum EDID_AUDIO_FORMAT_ID { 28 | LPCM = 1, 29 | AC3, 30 | MPEG1, 31 | MP3, 32 | MPEG2_MULTI_CHANNEL, 33 | AAC, 34 | DTS, 35 | ATRAC, 36 | SACD, 37 | DOLBY_DIGITAL_PLUS, 38 | DTS_HD, 39 | MAT, 40 | DST, 41 | WMA_PRO 42 | } EDID_AUDIO_FORMAT_ID; 43 | 44 | typedef struct EDID_AUDIO_BLOCK_INFO { 45 | EDID_AUDIO_FORMAT_ID nFormatId; 46 | int nSamplingFreq; 47 | int nBitsPerSample; 48 | int nChannels; 49 | } EDID_AUDIO_BLOCK_INFO; 50 | 51 | typedef struct EDID_AUDIO_INFO { 52 | int nAudioBlocks; 53 | unsigned char nSpeakerAllocation[MIN_SPKR_ALLOCATION_DATA_LENGTH]; 54 | EDID_AUDIO_BLOCK_INFO AudioBlocksArray[MAX_EDID_BLOCKS]; 55 | } EDID_AUDIO_INFO; 56 | 57 | class AudioUtil { 58 | public: 59 | 60 | //Parses EDID audio block when if HDMI is connected to determine audio sink capabilities. 61 | static bool getHDMIAudioSinkCaps(EDID_AUDIO_INFO*); 62 | 63 | private: 64 | static int printFormatFromEDID(unsigned char format); 65 | static int getSamplingFrequencyFromEDID(unsigned char byte); 66 | static int getBitsPerSampleFromEDID(unsigned char byte, 67 | unsigned char format); 68 | static bool getSpeakerAllocation(EDID_AUDIO_INFO* pInfo); 69 | }; 70 | 71 | #endif /* ALSA_SOUND_AUDIO_UTIL_H */ 72 | -------------------------------------------------------------------------------- /hal/acdb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ACDB_H 18 | #define ACDB_H 19 | 20 | #include 21 | #include 22 | 23 | #define MAX_CVD_VERSION_STRING_SIZE 100 24 | #define LIB_ACDB_LOADER "libacdbloader.so" 25 | #define CVD_VERSION_MIXER_CTL "CVD Version" 26 | #define ACDB_METAINFO_KEY_MODULE_NAME_LEN 100 27 | 28 | /* Audio calibration related functions */ 29 | typedef void (*acdb_deallocate_t)(); 30 | typedef int (*acdb_init_v3_t)(const char *, char *, struct listnode *); 31 | typedef int (*acdb_init_v2_cvd_t)(char *, char *, int); 32 | typedef int (*acdb_init_v2_t)(char *); 33 | typedef int (*acdb_init_t)(); 34 | typedef void (*acdb_send_audio_cal_t)(int, int); 35 | typedef void (*acdb_send_voice_cal_t)(int, int); 36 | typedef int (*acdb_get_audio_cal_t) (void *, void *, uint32_t*); 37 | typedef int (*acdb_reload_vocvoltable_t)(int); 38 | typedef int (*acdb_send_gain_dep_cal_t)(int, int, int, int, int); 39 | typedef int (*acdb_send_custom_top_t) (void); 40 | typedef int (*acdb_set_audio_cal_t) (void *, void *, uint32_t); 41 | 42 | struct meta_key_list { 43 | struct listnode list; 44 | struct audio_cal_info_metainfo cal_info; 45 | char name[ACDB_METAINFO_KEY_MODULE_NAME_LEN]; 46 | }; 47 | 48 | struct acdb_platform_data { 49 | /* Audio calibration related functions */ 50 | void *acdb_handle; 51 | acdb_init_t acdb_init; 52 | acdb_init_v2_cvd_t acdb_init_v2; 53 | acdb_init_v3_t acdb_init_v3; 54 | char *snd_card_name; 55 | struct listnode acdb_meta_key_list; 56 | }; 57 | 58 | int acdb_init(int); 59 | 60 | int acdb_set_metainfo_key(void *platform, char *name, int key); 61 | int acdb_set_parameters(void *platform, struct str_parms *parms); 62 | #endif //ACDB_H 63 | -------------------------------------------------------------------------------- /legacy/libalsa-intf/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true) 4 | # Any prebuilt files with default TAGS can use the below: 5 | 6 | include $(CLEAR_VARS) 7 | #LOCAL_SRC_FILES:= aplay.c alsa_pcm.c alsa_mixer.c 8 | LOCAL_SRC_FILES:= aplay.c 9 | LOCAL_MODULE:= aplay 10 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-LGPL 11 | LOCAL_LICENSE_CONDITIONS:= notice restricted 12 | LOCAL_SHARED_LIBRARIES:= libc libcutils libalsa-intf 13 | LOCAL_MODULE_TAGS:= debug 14 | include $(BUILD_EXECUTABLE) 15 | 16 | include $(CLEAR_VARS) 17 | #LOCAL_SRC_FILES:= arec.c alsa_pcm.c 18 | LOCAL_SRC_FILES:= arec.c 19 | LOCAL_MODULE:= arec 20 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-LGPL 21 | LOCAL_LICENSE_CONDITIONS:= notice restricted 22 | LOCAL_SHARED_LIBRARIES:= libc libcutils libalsa-intf 23 | LOCAL_MODULE_TAGS:= debug 24 | include $(BUILD_EXECUTABLE) 25 | 26 | include $(CLEAR_VARS) 27 | LOCAL_SRC_FILES:= amix.c 28 | LOCAL_MODULE:= amix 29 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-LGPL 30 | LOCAL_LICENSE_CONDITIONS:= notice restricted 31 | LOCAL_SHARED_LIBRARIES := libc libcutils libalsa-intf 32 | LOCAL_MODULE_TAGS:= debug 33 | include $(BUILD_EXECUTABLE) 34 | 35 | include $(CLEAR_VARS) 36 | LOCAL_SRC_FILES:= alsaucm_test.c 37 | LOCAL_MODULE:= alsaucm_test 38 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-LGPL 39 | LOCAL_LICENSE_CONDITIONS:= notice restricted 40 | LOCAL_SHARED_LIBRARIES:= libc libcutils libalsa-intf 41 | LOCAL_MODULE_TAGS:= debug 42 | include $(BUILD_EXECUTABLE) 43 | 44 | include $(CLEAR_VARS) 45 | LOCAL_COPY_HEADERS_TO := mm-audio/libalsa-intf 46 | LOCAL_COPY_HEADERS := alsa_audio.h 47 | LOCAL_COPY_HEADERS += alsa_ucm.h 48 | LOCAL_COPY_HEADERS += msm8960_use_cases.h 49 | LOCAL_SRC_FILES:= alsa_mixer.c alsa_pcm.c alsa_ucm.c 50 | LOCAL_MODULE:= libalsa-intf 51 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD SPDX-license-identifier-LGPL 52 | LOCAL_LICENSE_CONDITIONS:= notice restricted 53 | LOCAL_MODULE_TAGS := optional 54 | LOCAL_SHARED_LIBRARIES:= libc libcutils #libutils #libmedia libhardware_legacy 55 | LOCAL_CFLAGS := -DQC_PROP -DCONFIG_DIR=\"/system/etc/snd_soc_msm/\" 56 | 57 | LOCAL_SHARED_LIBRARIES += libdl 58 | include $(BUILD_SHARED_LIBRARY) 59 | endif 60 | -------------------------------------------------------------------------------- /legacy/alsa_sound/CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/audio_policy.conf) 48 | 49 | # ************************************************ 50 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 51 | # ************************************************ 52 | -------------------------------------------------------------------------------- /legacy/libalsa-intf/amix.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2010, The Android Open-Source Project 3 | ** Copyright (c) 2011, Code Aurora Forum. All rights reserved. 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "alsa_audio.h" 32 | 33 | 34 | struct mixer_ctl *get_ctl(struct mixer *mixer, char *name) 35 | { 36 | char *p; 37 | unsigned idx = 0; 38 | 39 | if (isdigit(name[0])) 40 | return mixer_get_nth_control(mixer, atoi(name) - 1); 41 | 42 | p = strrchr(name, '#'); 43 | if (p) { 44 | *p++ = 0; 45 | idx = atoi(p); 46 | } 47 | 48 | return mixer_get_control(mixer, name, idx); 49 | } 50 | 51 | int main(int argc, char **argv) 52 | { 53 | struct mixer *mixer; 54 | struct mixer_ctl *ctl; 55 | unsigned value; 56 | int r; 57 | const char* device = "/dev/snd/controlC0"; 58 | 59 | mixer = mixer_open(device); 60 | if (!mixer){ 61 | fprintf(stderr,"oops: %s: %d\n", strerror(errno), __LINE__); 62 | return -1; 63 | } 64 | 65 | if (argc == 1) { 66 | mixer_dump(mixer); 67 | mixer_close(mixer); 68 | return 0; 69 | } 70 | 71 | ctl = get_ctl(mixer, argv[1]); 72 | argc -= 2; 73 | argv += 2; 74 | 75 | if (!ctl) { 76 | fprintf(stderr,"can't find control\n"); 77 | mixer_close(mixer); 78 | return -1; 79 | } 80 | if (argc) { 81 | if (isdigit(argv[0][0])) 82 | r = mixer_ctl_set_value(ctl, argc, argv); 83 | else 84 | r = mixer_ctl_select(ctl, argv[0]); 85 | if (r) 86 | fprintf(stderr,"oops: %s: %d\n", strerror(errno), __LINE__); 87 | } else { 88 | mixer_ctl_get(ctl, &value); 89 | } 90 | mixer_close(mixer); 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /post_proc/reverb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFFLOAD_REVERB_H_ 18 | #define OFFLOAD_REVERB_H_ 19 | 20 | #include "bundle.h" 21 | 22 | #define REVERB_DEFAULT_PRESET REVERB_PRESET_NONE 23 | 24 | extern const effect_descriptor_t aux_env_reverb_descriptor; 25 | extern const effect_descriptor_t ins_env_reverb_descriptor; 26 | extern const effect_descriptor_t aux_preset_reverb_descriptor; 27 | extern const effect_descriptor_t ins_preset_reverb_descriptor; 28 | 29 | typedef struct reverb_settings_s { 30 | int16_t roomLevel; 31 | int16_t roomHFLevel; 32 | uint32_t decayTime; 33 | int16_t decayHFRatio; 34 | int16_t reflectionsLevel; 35 | uint32_t reflectionsDelay; 36 | int16_t reverbLevel; 37 | uint32_t reverbDelay; 38 | int16_t diffusion; 39 | int16_t density; 40 | } reverb_settings_t; 41 | 42 | typedef struct reverb_context_s { 43 | effect_context_t common; 44 | 45 | // Offload vars 46 | struct mixer_ctl *ctl; 47 | bool auxiliary; 48 | bool preset; 49 | uint16_t cur_preset; 50 | uint16_t next_preset; 51 | reverb_settings_t reverb_settings; 52 | uint32_t device; 53 | struct reverb_params offload_reverb; 54 | } reverb_context_t; 55 | 56 | 57 | void reverb_auxiliary_init(reverb_context_t *context); 58 | 59 | void reverb_preset_init(reverb_context_t *context); 60 | 61 | void reverb_insert_init(reverb_context_t *context); 62 | 63 | int reverb_get_parameter(effect_context_t *context, effect_param_t *p, 64 | uint32_t *size); 65 | 66 | int reverb_set_parameter(effect_context_t *context, effect_param_t *p, 67 | uint32_t size); 68 | 69 | int reverb_set_device(effect_context_t *context, uint32_t device); 70 | 71 | int reverb_reset(effect_context_t *context); 72 | 73 | int reverb_init(effect_context_t *context); 74 | 75 | int reverb_enable(effect_context_t *context); 76 | 77 | int reverb_disable(effect_context_t *context); 78 | 79 | int reverb_start(effect_context_t *context, output_context_t *output); 80 | 81 | int reverb_stop(effect_context_t *context, output_context_t *output); 82 | 83 | #endif /* OFFLOAD_REVERB_H_ */ 84 | -------------------------------------------------------------------------------- /legacy/alsa_sound/acoustics_default.cpp: -------------------------------------------------------------------------------- 1 | /* acoustics_default.cpp 2 | ** 3 | ** Copyright 2009 Wind River Systems 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #define LOG_TAG "AcousticsModule" 19 | #include 20 | 21 | #include "AudioHardwareALSA.h" 22 | 23 | namespace android 24 | { 25 | 26 | static int s_device_open(const hw_module_t*, const char*, hw_device_t**); 27 | static int s_device_close(hw_device_t*); 28 | 29 | static status_t s_use_handle(acoustic_device_t *, alsa_handle_t *); 30 | static status_t s_cleanup(acoustic_device_t *); 31 | static status_t s_set_params(acoustic_device_t *, 32 | AudioSystem::audio_in_acoustics, void *params); 33 | 34 | static hw_module_methods_t s_module_methods = { 35 | open : s_device_open 36 | }; 37 | 38 | extern "C" hw_module_t HAL_MODULE_INFO_SYM = { 39 | tag : HARDWARE_MODULE_TAG, 40 | version_major : 1, 41 | version_minor : 0, 42 | id : ACOUSTICS_HARDWARE_MODULE_ID, 43 | name : "ALSA acoustics module", 44 | author : "Wind River", 45 | methods : &s_module_methods, 46 | dso : 0, 47 | reserved : { 0, }, 48 | }; 49 | 50 | static int s_device_open(const hw_module_t* module, const char* name, 51 | hw_device_t** device) 52 | { 53 | acoustic_device_t *dev; 54 | dev = (acoustic_device_t *) malloc(sizeof(*dev)); 55 | if (!dev) return -ENOMEM; 56 | 57 | memset(dev, 0, sizeof(*dev)); 58 | 59 | /* initialize the procs */ 60 | dev->common.tag = HARDWARE_DEVICE_TAG; 61 | dev->common.version = 0; 62 | dev->common.module = (hw_module_t *) module; 63 | dev->common.close = s_device_close; 64 | 65 | // Required methods... 66 | dev->use_handle = s_use_handle; 67 | dev->cleanup = s_cleanup; 68 | dev->set_params = s_set_params; 69 | 70 | // read, write, and recover are optional methods... 71 | 72 | *device = &dev->common; 73 | return 0; 74 | } 75 | 76 | static int s_device_close(hw_device_t* device) 77 | { 78 | free(device); 79 | return 0; 80 | } 81 | 82 | static status_t s_use_handle(acoustic_device_t *dev, alsa_handle_t *h) 83 | { 84 | return NO_ERROR; 85 | } 86 | 87 | static status_t s_cleanup(acoustic_device_t *dev) 88 | { 89 | ALOGD("Acoustics close stub called."); 90 | return NO_ERROR; 91 | } 92 | 93 | static status_t s_set_params(acoustic_device_t *dev, 94 | AudioSystem::audio_in_acoustics acoustics, void *params) 95 | { 96 | ALOGD("Acoustics set_params stub called with %d.", (int)acoustics); 97 | return NO_ERROR; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /post_proc/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(filter msm8974 msm8226 msm8084 msm8992 msm8994 msm8996 msm8909 msm8998 sdm845 sdm710 msmnile,$(TARGET_BOARD_PLATFORM)),) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | qcom_post_proc_common_cflags := \ 6 | -O2 -fvisibility=hidden \ 7 | -Wall -Werror \ 8 | -Wno-unused-function \ 9 | -Wno-unused-variable \ 10 | 11 | include $(CLEAR_VARS) 12 | 13 | LOCAL_SRC_FILES:= \ 14 | bundle.c \ 15 | equalizer.c \ 16 | bass_boost.c \ 17 | virtualizer.c \ 18 | reverb.c \ 19 | effect_api.c 20 | 21 | LOCAL_CFLAGS += $(qcom_post_proc_common_cflags) 22 | 23 | LOCAL_SHARED_LIBRARIES := \ 24 | libcutils \ 25 | liblog \ 26 | libtinyalsa 27 | 28 | LOCAL_MODULE_TAGS := optional 29 | LOCAL_MODULE_OWNER := qcom 30 | LOCAL_PROPRIETARY_MODULE := true 31 | 32 | LOCAL_MODULE_RELATIVE_PATH := soundfx 33 | LOCAL_MODULE:= libqcompostprocbundle 34 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 35 | LOCAL_LICENSE_CONDITIONS:= notice 36 | 37 | LOCAL_C_INCLUDES := \ 38 | external/tinyalsa/include \ 39 | $(call include-path-for, audio-effects) 40 | 41 | LOCAL_HEADER_LIBRARIES += libhardware_headers 42 | LOCAL_HEADER_LIBRARIES += libsystem_headers 43 | include $(BUILD_SHARED_LIBRARY) 44 | endif 45 | 46 | ################################################################################ 47 | 48 | ifneq ($(filter msm8992 msm8994 msm8996 msm8909 msm8998 sdm845 sdm710 msmnile,$(TARGET_BOARD_PLATFORM)),) 49 | 50 | include $(CLEAR_VARS) 51 | 52 | LOCAL_CFLAGS := -DLIB_AUDIO_HAL="audio.primary."$(TARGET_BOARD_PLATFORM)".so" 53 | 54 | LOCAL_SRC_FILES:= \ 55 | volume_listener.c 56 | 57 | LOCAL_CFLAGS += $(qcom_post_proc_common_cflags) 58 | 59 | LOCAL_SHARED_LIBRARIES := \ 60 | libcutils \ 61 | liblog \ 62 | libdl 63 | 64 | LOCAL_MODULE_RELATIVE_PATH := soundfx 65 | LOCAL_MODULE:= libvolumelistener 66 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 67 | LOCAL_LICENSE_CONDITIONS:= notice 68 | LOCAL_MODULE_OWNER := qcom 69 | LOCAL_PROPRIETARY_MODULE := true 70 | 71 | LOCAL_C_INCLUDES := \ 72 | hardware/qcom/audio/hal \ 73 | $(call include-path-for, audio-effects) 74 | 75 | LOCAL_HEADER_LIBRARIES += libhardware_headers 76 | LOCAL_HEADER_LIBRARIES += libsystem_headers 77 | include $(BUILD_SHARED_LIBRARY) 78 | 79 | endif 80 | 81 | ################################################################################ 82 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MAXX_AUDIO)), true) 83 | 84 | include $(CLEAR_VARS) 85 | 86 | LOCAL_CFLAGS := -D HAL_LIB_NAME=\"audio.primary."$(TARGET_BOARD_PLATFORM)".so\" 87 | 88 | LOCAL_SRC_FILES:= \ 89 | ma_listener.c 90 | 91 | LOCAL_CFLAGS += $(qcom_post_proc_common_cflags) 92 | 93 | LOCAL_SHARED_LIBRARIES := \ 94 | libcutils \ 95 | liblog \ 96 | libdl 97 | 98 | LOCAL_MODULE_RELATIVE_PATH := soundfx 99 | LOCAL_MODULE:= libmalistener 100 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 101 | LOCAL_LICENSE_CONDITIONS:= notice 102 | LOCAL_MODULE_OWNER := google 103 | LOCAL_PROPRIETARY_MODULE := true 104 | 105 | LOCAL_C_INCLUDES := \ 106 | hardware/qcom/audio/hal \ 107 | system/media/audio/include/system \ 108 | $(call include-path-for, audio-effects) 109 | 110 | LOCAL_HEADER_LIBRARIES += libhardware_headers 111 | LOCAL_HEADER_LIBRARIES += libsystem_headers 112 | include $(BUILD_SHARED_LIBRARY) 113 | 114 | endif 115 | -------------------------------------------------------------------------------- /post_proc/bundle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFFLOAD_EFFECT_BUNDLE_H 18 | #define OFFLOAD_EFFECT_BUNDLE_H 19 | 20 | #include 21 | #include 22 | #include "effect_api.h" 23 | 24 | /* Retry for delay for mixer open */ 25 | #define RETRY_NUMBER 10 26 | #define RETRY_US 500000 27 | 28 | #define MIXER_CARD 0 29 | #define SOUND_CARD 0 30 | 31 | extern const struct effect_interface_s effect_interface; 32 | 33 | typedef struct output_context_s output_context_t; 34 | typedef struct effect_ops_s effect_ops_t; 35 | typedef struct effect_context_s effect_context_t; 36 | 37 | struct output_context_s { 38 | /* node in active_outputs_list */ 39 | struct listnode outputs_list_node; 40 | /* io handle */ 41 | audio_io_handle_t handle; 42 | /* list of effects attached to this output */ 43 | struct listnode effects_list; 44 | /* pcm device id */ 45 | int pcm_device_id; 46 | struct mixer *mixer; 47 | struct mixer_ctl *ctl; 48 | }; 49 | 50 | /* effect specific operations. 51 | * Only the init() and process() operations must be defined. 52 | * Others are optional. 53 | */ 54 | struct effect_ops_s { 55 | int (*init)(effect_context_t *context); 56 | int (*release)(effect_context_t *context); 57 | int (*reset)(effect_context_t *context); 58 | int (*enable)(effect_context_t *context); 59 | int (*start)(effect_context_t *context, output_context_t *output); 60 | int (*stop)(effect_context_t *context, output_context_t *output); 61 | int (*disable)(effect_context_t *context); 62 | int (*process)(effect_context_t *context, audio_buffer_t *in, audio_buffer_t *out); 63 | int (*set_parameter)(effect_context_t *context, effect_param_t *param, uint32_t size); 64 | int (*get_parameter)(effect_context_t *context, effect_param_t *param, uint32_t *size); 65 | int (*set_device)(effect_context_t *context, uint32_t device); 66 | int (*command)(effect_context_t *context, uint32_t cmdCode, uint32_t cmdSize, 67 | void *pCmdData, uint32_t *replySize, void *pReplyData); 68 | }; 69 | 70 | struct effect_context_s { 71 | const struct effect_interface_s *itfe; 72 | /* node in created_effects_list */ 73 | struct listnode effects_list_node; 74 | /* node in output_context_t.effects_list */ 75 | struct listnode output_node; 76 | effect_config_t config; 77 | const effect_descriptor_t *desc; 78 | /* io handle of the output the effect is attached to */ 79 | audio_io_handle_t out_handle; 80 | uint32_t state; 81 | bool offload_enabled; 82 | effect_ops_t ops; 83 | }; 84 | 85 | int set_config(effect_context_t *context, effect_config_t *config); 86 | 87 | bool effect_is_active(effect_context_t *context); 88 | 89 | #endif /* OFFLOAD_EFFECT_BUNDLE_H */ 90 | -------------------------------------------------------------------------------- /hal/audio_extn/dsm_feedback.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "audio_hw_dsm_feedback" 18 | /*#define LOG_NDEBUG 0*/ 19 | #define LOG_NDDEBUG 0 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "audio_hw.h" 26 | #include "platform.h" 27 | #include "platform_api.h" 28 | #include 29 | 30 | 31 | static struct pcm_config pcm_config_dsm = { 32 | .channels = 2, 33 | .rate = 48000, 34 | .period_size = 256, 35 | .period_count = 4, 36 | .format = PCM_FORMAT_S16_LE, 37 | .start_threshold = 0, 38 | .stop_threshold = INT_MAX, 39 | .avail_min = 0, 40 | }; 41 | 42 | int start_dsm_feedback_processing(struct audio_device *adev, int enable) 43 | { 44 | int ret = 0; 45 | int32_t pcm_dev_tx_id = -1; 46 | static struct pcm *dsm_pcm_handle = NULL; 47 | 48 | if (enable) { 49 | /*do nothing if already enabled*/ 50 | if (dsm_pcm_handle) 51 | return ret; 52 | 53 | pcm_dev_tx_id = platform_get_pcm_device_id(USECASE_AUDIO_DSM_FEEDBACK, PCM_CAPTURE); 54 | if (pcm_dev_tx_id < 0) { 55 | ALOGE("%s: Invalid pcm device for usecase (%d)", 56 | __func__, USECASE_AUDIO_DSM_FEEDBACK); 57 | ret = -ENODEV; 58 | goto close; 59 | } 60 | 61 | dsm_pcm_handle = pcm_open(adev->snd_card, 62 | pcm_dev_tx_id, 63 | PCM_IN, &pcm_config_dsm); 64 | if (dsm_pcm_handle && !pcm_is_ready(dsm_pcm_handle)) { 65 | ALOGE("%s: %s", __func__, pcm_get_error(dsm_pcm_handle)); 66 | ret = -EIO; 67 | goto close; 68 | } 69 | 70 | if (pcm_start(dsm_pcm_handle) < 0) { 71 | ALOGE("%s: pcm start for RX failed", __func__); 72 | ret = -EINVAL; 73 | goto close; 74 | } 75 | 76 | return ret; 77 | } 78 | 79 | close: 80 | /*close pcm if disable or error happend in opening*/ 81 | if (dsm_pcm_handle) { 82 | pcm_close(dsm_pcm_handle); 83 | dsm_pcm_handle = NULL; 84 | } 85 | 86 | return ret; 87 | } 88 | 89 | void audio_extn_dsm_feedback_enable(struct audio_device *adev, 90 | snd_device_t snd_device, 91 | int benable) 92 | { 93 | if ( NULL == adev ) 94 | return; 95 | 96 | if( snd_device == SND_DEVICE_OUT_SPEAKER || 97 | snd_device == SND_DEVICE_OUT_SPEAKER_REVERSE || 98 | snd_device == SND_DEVICE_OUT_VOICE_SPEAKER || 99 | snd_device == SND_DEVICE_OUT_SPEAKER_SAFE || 100 | snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES || 101 | snd_device == SND_DEVICE_OUT_SPEAKER_AND_LINE || 102 | snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES || 103 | snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE ) 104 | start_dsm_feedback_processing(adev, benable); 105 | } 106 | -------------------------------------------------------------------------------- /hal/voice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VOICE_H 18 | #define VOICE_H 19 | 20 | #define BASE_SESS_IDX 0 21 | #define VOICE_SESS_IDX (BASE_SESS_IDX) 22 | 23 | #ifdef MULTI_VOICE_SESSION_ENABLED 24 | #define MAX_VOICE_SESSIONS 7 25 | #else 26 | #define MAX_VOICE_SESSIONS 1 27 | #endif 28 | 29 | #define BASE_CALL_STATE 1 30 | #define CALL_INACTIVE (BASE_CALL_STATE) 31 | #define CALL_ACTIVE (BASE_CALL_STATE + 1) 32 | 33 | #define VOICE_VSID 0x10C01000 34 | 35 | #define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled" 36 | #define AUDIO_PARAMETER_VALUE_TRUE "true" 37 | 38 | struct audio_device; 39 | struct str_parms; 40 | struct stream_in; 41 | struct stream_out; 42 | typedef int audio_usecase_t; 43 | typedef int snd_device_t; 44 | 45 | struct call_state { 46 | int current; 47 | int new; 48 | }; 49 | 50 | struct voice_session { 51 | struct pcm *pcm_rx; 52 | struct pcm *pcm_tx; 53 | struct call_state state; 54 | uint32_t vsid; 55 | }; 56 | 57 | struct voice { 58 | struct voice_session session[MAX_VOICE_SESSIONS]; 59 | int tty_mode; 60 | bool hac; 61 | bool mic_mute; 62 | float volume; 63 | bool in_call; 64 | }; 65 | 66 | enum { 67 | INCALL_REC_NONE = -1, 68 | INCALL_REC_UPLINK, 69 | INCALL_REC_DOWNLINK, 70 | INCALL_REC_UPLINK_AND_DOWNLINK, 71 | }; 72 | 73 | int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id); 74 | int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id); 75 | 76 | int voice_start_call(struct audio_device *adev); 77 | int voice_stop_call(struct audio_device *adev); 78 | int voice_set_parameters(struct audio_device *adev, struct str_parms *parms); 79 | void voice_get_parameters(struct audio_device *adev, struct str_parms *query, 80 | struct str_parms *reply); 81 | void voice_init(struct audio_device *adev); 82 | bool voice_is_in_call(struct audio_device *adev); 83 | bool voice_is_in_call_rec_stream(struct stream_in *in); 84 | int voice_set_mic_mute(struct audio_device *dev, bool state); 85 | bool voice_get_mic_mute(struct audio_device *dev); 86 | int voice_set_volume(struct audio_device *adev, float volume); 87 | int voice_check_and_set_incall_rec_usecase(struct audio_device *adev, 88 | struct stream_in *in); 89 | int voice_check_and_set_incall_music_usecase(struct audio_device *adev, 90 | struct stream_out *out); 91 | int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev, 92 | struct stream_in *in); 93 | void voice_update_devices_for_all_voice_usecases(struct audio_device *adev); 94 | void voice_set_sidetone(struct audio_device *adev, 95 | snd_device_t out_snd_device, 96 | bool enable); 97 | bool voice_is_call_state_active(struct audio_device *adev); 98 | void voice_set_device_mute_flag (struct audio_device *adev, bool state); 99 | 100 | #endif //VOICE_H 101 | -------------------------------------------------------------------------------- /hal/voice_extn/voice_extn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VOICE_EXTN_H 18 | #define VOICE_EXTN_H 19 | 20 | #ifdef MULTI_VOICE_SESSION_ENABLED 21 | int voice_extn_start_call(struct audio_device *adev); 22 | int voice_extn_stop_call(struct audio_device *adev); 23 | int voice_extn_get_session_from_use_case(struct audio_device *adev, 24 | const audio_usecase_t usecase_id, 25 | struct voice_session **session); 26 | void voice_extn_init(struct audio_device *adev); 27 | int voice_extn_set_parameters(struct audio_device *adev, 28 | struct str_parms *parms); 29 | void voice_extn_get_parameters(const struct audio_device *adev, 30 | struct str_parms *query, 31 | struct str_parms *reply); 32 | int voice_extn_is_in_call_rec_stream(struct stream_in *in, bool *in_call_rec); 33 | int voice_extn_get_active_session_id(struct audio_device *adev, 34 | uint32_t *session_id); 35 | int voice_extn_is_call_state_active(struct audio_device *adev, 36 | bool *is_call_active); 37 | #else 38 | static int voice_extn_start_call(struct audio_device *adev __unused) 39 | { 40 | return -ENOSYS; 41 | } 42 | 43 | static int voice_extn_stop_call(struct audio_device *adev __unused) 44 | { 45 | return -ENOSYS; 46 | } 47 | 48 | static int voice_extn_get_session_from_use_case(struct audio_device *adev __unused, 49 | const audio_usecase_t usecase_id __unused, 50 | struct voice_session **session __unused) 51 | { 52 | return -ENOSYS; 53 | } 54 | 55 | static void voice_extn_init(struct audio_device *adev __unused) 56 | { 57 | } 58 | 59 | static int voice_extn_set_parameters(struct audio_device *adev __unused, 60 | struct str_parms *parms __unused) 61 | { 62 | return -ENOSYS; 63 | } 64 | 65 | static void voice_extn_get_parameters(const struct audio_device *adev __unused, 66 | struct str_parms *query __unused, 67 | struct str_parms *reply __unused) 68 | { 69 | } 70 | 71 | static int voice_extn_is_call_state_active(struct audio_device *adev __unused, 72 | bool *is_call_active __unused) 73 | { 74 | return -ENOSYS; 75 | } 76 | 77 | static int voice_extn_is_in_call_rec_stream(struct stream_in *in __unused, bool *in_call_rec __unused) 78 | { 79 | return -ENOSYS; 80 | } 81 | 82 | static int voice_extn_get_active_session_id(struct audio_device *adev __unused, 83 | uint32_t *session_id __unused) 84 | { 85 | return -ENOSYS; 86 | } 87 | 88 | #endif 89 | 90 | #ifdef INCALL_MUSIC_ENABLED 91 | int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev, 92 | struct stream_out *out); 93 | #else 94 | static int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev __unused, 95 | struct stream_out *out __unused) 96 | { 97 | return -ENOSYS; 98 | } 99 | #endif 100 | 101 | #endif //VOICE_EXTN_H 102 | -------------------------------------------------------------------------------- /legacy/alsa_sound/ALSAControl.cpp: -------------------------------------------------------------------------------- 1 | /* ALSAControl.cpp 2 | ** 3 | ** Copyright 2008-2009 Wind River Systems 4 | ** Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. 5 | ** 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); 7 | ** you may not use this file except in compliance with the License. 8 | ** You may obtain a copy of the License at 9 | ** 10 | ** http://www.apache.org/licenses/LICENSE-2.0 11 | ** 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define LOG_TAG "ALSAControl" 28 | //#define LOG_NDEBUG 0 29 | #define LOG_NDDEBUG 0 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "AudioHardwareALSA.h" 38 | 39 | namespace android_audio_legacy 40 | { 41 | 42 | ALSAControl::ALSAControl(const char *device) 43 | { 44 | ALOGD("ALSAControl: ctor device %s", device); 45 | mHandle = mixer_open(device); 46 | ALOGV("ALSAControl: ctor mixer %p", mHandle); 47 | } 48 | 49 | ALSAControl::~ALSAControl() 50 | { 51 | if (mHandle) mixer_close(mHandle); 52 | } 53 | 54 | status_t ALSAControl::get(const char *name, unsigned int &value, int index) 55 | { 56 | struct mixer_ctl *ctl; 57 | 58 | if (!mHandle) { 59 | ALOGE("Control not initialized"); 60 | return NO_INIT; 61 | } 62 | 63 | ctl = mixer_get_control(mHandle, name, index); 64 | if (!ctl) 65 | return BAD_VALUE; 66 | 67 | mixer_ctl_get(ctl, &value); 68 | return NO_ERROR; 69 | } 70 | 71 | status_t ALSAControl::set(const char *name, unsigned int value, int index) 72 | { 73 | struct mixer_ctl *ctl; 74 | int ret = 0; 75 | ALOGD("set:: name %s value %d index %d", name, value, index); 76 | if (!mHandle) { 77 | ALOGE("Control not initialized"); 78 | return NO_INIT; 79 | } 80 | 81 | // ToDo: Do we need to send index here? Right now it works with 0 82 | ctl = mixer_get_control(mHandle, name, 0); 83 | if(ctl == NULL) { 84 | ALOGE("Could not get the mixer control"); 85 | return BAD_VALUE; 86 | } 87 | ret = mixer_ctl_set(ctl, value); 88 | return (ret < 0) ? BAD_VALUE : NO_ERROR; 89 | } 90 | 91 | status_t ALSAControl::set(const char *name, const char *value) 92 | { 93 | struct mixer_ctl *ctl; 94 | int ret = 0; 95 | ALOGD("set:: name %s value %s", name, value); 96 | 97 | if (!mHandle) { 98 | ALOGE("Control not initialized"); 99 | return NO_INIT; 100 | } 101 | 102 | ctl = mixer_get_control(mHandle, name, 0); 103 | if(ctl == NULL) { 104 | ALOGE("Could not get the mixer control"); 105 | return BAD_VALUE; 106 | } 107 | ret = mixer_ctl_select(ctl, value); 108 | return (ret < 0) ? BAD_VALUE : NO_ERROR; 109 | } 110 | 111 | status_t ALSAControl::setext(const char *name, int count, char **setValues) 112 | { 113 | struct mixer_ctl *ctl; 114 | int ret = 0; 115 | ALOGD("setext:: name %s count %d", name, count); 116 | if (!mHandle) { 117 | ALOGE("Control not initialized"); 118 | return NO_INIT; 119 | } 120 | 121 | // ToDo: Do we need to send index here? Right now it works with 0 122 | ctl = mixer_get_control(mHandle, name, 0); 123 | if(ctl == NULL) { 124 | ALOGE("Could not get the mixer control"); 125 | return BAD_VALUE; 126 | } 127 | ret = mixer_ctl_set_value(ctl, count, setValues); 128 | return (ret < 0) ? BAD_VALUE : NO_ERROR; 129 | } 130 | 131 | }; // namespace android 132 | -------------------------------------------------------------------------------- /legacy/alsa_sound/Android.mk: -------------------------------------------------------------------------------- 1 | # hardware/libaudio-alsa/Android.mk 2 | # 3 | # Copyright 2008 Wind River Systems 4 | # 5 | 6 | ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true) 7 | 8 | LOCAL_PATH := $(call my-dir) 9 | 10 | include $(CLEAR_VARS) 11 | 12 | LOCAL_ARM_MODE := arm 13 | LOCAL_CFLAGS := -D_POSIX_SOURCE 14 | LOCAL_CFLAGS += -DQCOM_CSDCLIENT_ENABLED 15 | LOCAL_CFLAGS += -DQCOM_ACDB_ENABLED 16 | 17 | ifeq ($(strip $(BOARD_USES_FLUENCE_INCALL)),true) 18 | LOCAL_CFLAGS += -DUSES_FLUENCE_INCALL 19 | endif 20 | 21 | ifeq ($(strip $(BOARD_USES_SEPERATED_AUDIO_INPUT)),true) 22 | LOCAL_CFLAGS += -DSEPERATED_AUDIO_INPUT 23 | endif 24 | 25 | LOCAL_SRC_FILES := \ 26 | AudioHardwareALSA.cpp \ 27 | AudioStreamOutALSA.cpp \ 28 | AudioStreamInALSA.cpp \ 29 | ALSAStreamOps.cpp \ 30 | audio_hw_hal.cpp \ 31 | AudioUsbALSA.cpp \ 32 | AudioUtil.cpp 33 | 34 | LOCAL_STATIC_LIBRARIES := \ 35 | libmedia_helper \ 36 | libaudiohw_legacy \ 37 | libaudiopolicy_legacy \ 38 | 39 | LOCAL_SHARED_LIBRARIES := \ 40 | libcutils \ 41 | libutils \ 42 | libmedia \ 43 | libhardware \ 44 | libc \ 45 | libpower \ 46 | libalsa-intf 47 | 48 | LOCAL_SHARED_LIBRARIES += libdl 49 | 50 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-alsa 51 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/libalsa-intf 52 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/surround_sound/ 53 | LOCAL_C_INCLUDES += hardware/libhardware/include 54 | LOCAL_C_INCLUDES += hardware/libhardware_legacy/include 55 | LOCAL_C_INCLUDES += frameworks/base/include 56 | LOCAL_C_INCLUDES += system/core/include 57 | 58 | 59 | LOCAL_MODULE := audio.primary.msm8960 60 | LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD 61 | LOCAL_LICENSE_CONDITIONS := notice 62 | LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE 63 | LOCAL_MODULE_RELATIVE_PATH := hw 64 | LOCAL_MODULE_TAGS := optional 65 | 66 | include $(BUILD_SHARED_LIBRARY) 67 | 68 | # This is the ALSA audio policy manager 69 | 70 | include $(CLEAR_VARS) 71 | 72 | LOCAL_CFLAGS := -D_POSIX_SOURCE 73 | LOCAL_CFLAGS += -DQCOM_ACDB_ENABLED 74 | 75 | LOCAL_SRC_FILES := \ 76 | audio_policy_hal.cpp \ 77 | AudioPolicyManagerALSA.cpp 78 | 79 | LOCAL_MODULE := audio_policy.msm8960 80 | LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD 81 | LOCAL_LICENSE_CONDITIONS := notice 82 | LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE 83 | LOCAL_MODULE_RELATIVE_PATH := hw 84 | LOCAL_MODULE_TAGS := optional 85 | 86 | LOCAL_STATIC_LIBRARIES := \ 87 | libmedia_helper \ 88 | libaudiopolicy_legacy 89 | 90 | LOCAL_SHARED_LIBRARIES := \ 91 | libcutils \ 92 | libutils 93 | 94 | LOCAL_C_INCLUDES += hardware/libhardware_legacy/audio 95 | 96 | include $(BUILD_SHARED_LIBRARY) 97 | 98 | # This is the ALSA module which behaves closely like the original 99 | 100 | include $(CLEAR_VARS) 101 | 102 | 103 | LOCAL_MODULE_RELATIVE_PATH := hw 104 | 105 | LOCAL_CFLAGS := -D_POSIX_SOURCE -Wno-multichar 106 | LOCAL_CFLAGS += -DQCOM_ACDB_ENABLED 107 | 108 | ifeq ($(strip $(BOARD_USES_FLUENCE_INCALL)),true) 109 | LOCAL_CFLAGS += -DUSES_FLUENCE_INCALL 110 | endif 111 | 112 | ifeq ($(strip $(BOARD_USES_SEPERATED_AUDIO_INPUT)),true) 113 | LOCAL_CFLAGS += -DSEPERATED_AUDIO_INPUT 114 | endif 115 | 116 | ifneq ($(ALSA_DEFAULT_SAMPLE_RATE),) 117 | LOCAL_CFLAGS += -DALSA_DEFAULT_SAMPLE_RATE=$(ALSA_DEFAULT_SAMPLE_RATE) 118 | endif 119 | 120 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/libalsa-intf 121 | 122 | LOCAL_SRC_FILES:= \ 123 | alsa_default.cpp \ 124 | ALSAControl.cpp \ 125 | AudioUtil.cpp 126 | 127 | LOCAL_SHARED_LIBRARIES := \ 128 | libcutils \ 129 | liblog \ 130 | libalsa-intf 131 | 132 | LOCAL_SHARED_LIBRARIES += libdl 133 | 134 | LOCAL_MODULE:= alsa.msm8960 135 | LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD 136 | LOCAL_LICENSE_CONDITIONS:= notice 137 | LOCAL_NOTICE_FILE:= $(LOCAL_PATH)/NOTICE 138 | LOCAL_MODULE_TAGS := optional 139 | 140 | include $(BUILD_SHARED_LIBRARY) 141 | endif 142 | -------------------------------------------------------------------------------- /hal/msm8916/hw_info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "hardware_info" 18 | /*#define LOG_NDEBUG 0*/ 19 | #define LOG_NDDEBUG 0 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "audio_hw.h" 26 | #include "platform.h" 27 | #include "platform_api.h" 28 | 29 | 30 | struct hardware_info { 31 | char name[HW_INFO_ARRAY_MAX_SIZE]; 32 | char type[HW_INFO_ARRAY_MAX_SIZE]; 33 | /* variables for handling target variants */ 34 | uint32_t num_snd_devices; 35 | char dev_extn[HW_INFO_ARRAY_MAX_SIZE]; 36 | snd_device_t *snd_devices; 37 | }; 38 | 39 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 40 | 41 | 42 | static void update_hardware_info_8x16(struct hardware_info *hw_info, const char *snd_card_name) 43 | { 44 | if (!strcmp(snd_card_name, "msm8x16-snd-card") || 45 | !strcmp(snd_card_name, "msm8x16-snd-card-mtp")) { 46 | strlcpy(hw_info->name, "msm8x16", sizeof(hw_info->name)); 47 | } else if (!strcmp(snd_card_name, "msm8909-snd-card") || 48 | !strcmp(snd_card_name, "msm8909-pm8916-snd-card")) { 49 | strlcpy(hw_info->name, "msm8909", sizeof(hw_info->name)); 50 | } else if (!strcmp(snd_card_name, "msm-bg-snd-card")) { 51 | strlcpy(hw_info->name, "msm8909", sizeof(hw_info->name)); 52 | } else if (!strcmp(snd_card_name, "msm8952-snd-card") || 53 | !strcmp(snd_card_name, "msm8952-snd-card-mtp")) { 54 | strlcpy(hw_info->name, "msm8952", sizeof(hw_info->name)); 55 | } else if (!strcmp(snd_card_name, "msm8952-l9300-snd-card")) { 56 | strlcpy(hw_info->name, "msm8952", sizeof(hw_info->name)); 57 | } else { 58 | ALOGW("%s: Not an 8x16/8909/8952 device", __func__); 59 | } 60 | } 61 | 62 | void *hw_info_init(const char *snd_card_name) 63 | { 64 | struct hardware_info *hw_info; 65 | 66 | hw_info = malloc(sizeof(struct hardware_info)); 67 | if (!hw_info) { 68 | ALOGE("failed to allocate mem for hardware info"); 69 | return NULL; 70 | } 71 | 72 | if (strstr(snd_card_name, "msm8x16") || strstr(snd_card_name, "msm8909") 73 | || strstr(snd_card_name, "msm8952") || 74 | strstr(snd_card_name, "msm-bg-snd-card")) { 75 | ALOGV("8x16 - variant soundcard"); 76 | 77 | strlcpy(hw_info->type, "", sizeof(hw_info->type)); 78 | strlcpy(hw_info->name, "", sizeof(hw_info->name)); 79 | hw_info->snd_devices = NULL; 80 | hw_info->num_snd_devices = 0; 81 | strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn)); 82 | 83 | update_hardware_info_8x16(hw_info, snd_card_name); 84 | } else { 85 | ALOGE("%s: Unsupported target %s:",__func__, snd_card_name); 86 | free(hw_info); 87 | hw_info = NULL; 88 | } 89 | 90 | return hw_info; 91 | } 92 | 93 | void hw_info_deinit(void *hw_info) 94 | { 95 | struct hardware_info *my_data = (struct hardware_info*) hw_info; 96 | 97 | if(my_data) 98 | free(my_data); 99 | } 100 | 101 | void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device, 102 | char *device_name) 103 | { 104 | struct hardware_info *my_data = (struct hardware_info*) hw_info; 105 | uint32_t i = 0; 106 | 107 | if (my_data == NULL) 108 | return; 109 | 110 | snd_device_t *snd_devices = 111 | (snd_device_t *) my_data->snd_devices; 112 | 113 | if(snd_devices != NULL) { 114 | for (i = 0; i < my_data->num_snd_devices; i++) { 115 | if (snd_device == (snd_device_t)snd_devices[i]) { 116 | ALOGV("extract dev_extn device %d, extn = %s", 117 | (snd_device_t)snd_devices[i], my_data->dev_extn); 118 | CHECK(strlcat(device_name, my_data->dev_extn, 119 | DEVICE_NAME_MAX_SIZE) < DEVICE_NAME_MAX_SIZE); 120 | break; 121 | } 122 | } 123 | } 124 | ALOGD("%s : device_name = %s", __func__,device_name); 125 | } 126 | -------------------------------------------------------------------------------- /hal/audio_extn/hwdep_cal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "hardware_cal" 18 | /*#define LOG_NDEBUG 0*/ 19 | #define LOG_NDDEBUG 0 20 | 21 | #ifdef HWDEP_CAL_ENABLED 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "audio_extn.h" 31 | #include "sound/msmcal-hwdep.h" 32 | 33 | #define SOUND_TRIGGER_DEVICE_HANDSET_MONO_LOW_POWER_ACDB_ID (100) 34 | #define MAX_CAL_NAME 20 35 | 36 | typedef struct acdb_audio_cal_cfg { 37 | uint32_t persist; 38 | uint32_t snd_dev_id; 39 | audio_devices_t dev_id; 40 | int32_t acdb_dev_id; 41 | uint32_t app_type; 42 | uint32_t topo_id; 43 | uint32_t sampling_rate; 44 | uint32_t cal_type; 45 | uint32_t module_id; 46 | uint32_t param_id; 47 | } acdb_audio_cal_cfg_t; 48 | 49 | struct param_data { 50 | int use_case; 51 | int acdb_id; 52 | int get_size; 53 | int buff_size; 54 | int data_size; 55 | void *buff; 56 | }; 57 | 58 | char cal_name_info[WCD9XXX_MAX_CAL][MAX_CAL_NAME] = { 59 | [WCD9XXX_ANC_CAL] = "anc_cal", 60 | [WCD9XXX_MBHC_CAL] = "mbhc_cal", 61 | [WCD9XXX_MAD_CAL] = "mad_cal", 62 | }; 63 | 64 | typedef int (*acdb_get_calibration_t)(char *attr, int size, void *data); 65 | acdb_get_calibration_t acdb_get_calibration; 66 | 67 | static int hw_util_open(int card_no) 68 | { 69 | int fd = -1; 70 | char dev_name[256]; 71 | 72 | snprintf(dev_name, sizeof(dev_name), "/dev/snd/hwC%uD%u", 73 | card_no, WCD9XXX_CODEC_HWDEP_NODE); 74 | ALOGD("%s: Opening device %s\n", __func__, dev_name); 75 | fd = open(dev_name, O_WRONLY); 76 | if (fd < 0) { 77 | ALOGE("%s: cannot open device '%s'\n", __func__, dev_name); 78 | return fd; 79 | } 80 | ALOGD("%s: success", __func__); 81 | return fd; 82 | } 83 | 84 | static int send_codec_cal(acdb_get_calibration_t acdb_loader_get_calibration, int fd) 85 | { 86 | int ret = 0, type; 87 | 88 | for (type = WCD9XXX_ANC_CAL; type < WCD9XXX_MAX_CAL; type++) { 89 | struct wcdcal_ioctl_buffer codec_buffer; 90 | struct param_data calib; 91 | 92 | if (!strcmp(cal_name_info[type], "mad_cal")) 93 | calib.acdb_id = SOUND_TRIGGER_DEVICE_HANDSET_MONO_LOW_POWER_ACDB_ID; 94 | calib.get_size = 1; 95 | ret = acdb_loader_get_calibration(cal_name_info[type], sizeof(struct param_data), 96 | &calib); 97 | if (ret < 0) { 98 | ALOGE("%s get_calibration failed\n", __func__); 99 | return ret; 100 | } 101 | calib.get_size = 0; 102 | calib.buff = malloc(calib.buff_size); 103 | ret = acdb_loader_get_calibration(cal_name_info[type], 104 | sizeof(struct param_data), &calib); 105 | if (ret < 0) { 106 | ALOGE("%s get_calibration failed\n", __func__); 107 | free(calib.buff); 108 | return ret; 109 | } 110 | codec_buffer.buffer = calib.buff; 111 | codec_buffer.size = calib.data_size; 112 | codec_buffer.cal_type = type; 113 | if (ioctl(fd, SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE, &codec_buffer) < 0) 114 | ALOGE("Failed to call ioctl for %s err=%d", 115 | cal_name_info[type], errno); 116 | ALOGD("%s cal sent for %s", __func__, cal_name_info[type]); 117 | free(calib.buff); 118 | } 119 | return ret; 120 | } 121 | 122 | 123 | void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle) 124 | { 125 | int fd; 126 | 127 | fd = hw_util_open(snd_card); 128 | if (fd == -1) { 129 | ALOGE("%s error open\n", __func__); 130 | return; 131 | } 132 | 133 | acdb_get_calibration = (acdb_get_calibration_t) 134 | dlsym(acdb_handle, "acdb_loader_get_calibration"); 135 | 136 | if (acdb_get_calibration == NULL) { 137 | ALOGE("%s: ERROR. dlsym Error:%s acdb_loader_get_calibration", __func__, 138 | dlerror()); 139 | return; 140 | } 141 | if (send_codec_cal(acdb_get_calibration, fd) < 0) 142 | ALOGE("%s: Could not send anc cal", __FUNCTION__); 143 | 144 | close(fd); 145 | } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /legacy/alsa_sound/AudioUsbALSA.h: -------------------------------------------------------------------------------- 1 | /* AudioUsbALSA.h 2 | 3 | Copyright (c) 2012, Code Aurora Forum. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | * Neither the name of Code Aurora Forum, Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 28 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/ 29 | 30 | #ifndef ANDROID_AUDIO_USB_ALSA_H 31 | #define ANDROID_AUDIO_USB_ALSA_H 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define DEFAULT_BUFFER_SIZE 2048 43 | #define POLL_TIMEOUT 3000 44 | #define DEFAULT_CHANNEL_MODE 2 45 | #define CHANNEL_MODE_ONE 1 46 | #define PROXY_DEFAULT_SAMPLING_RATE 48000 47 | #define SIGNAL_EVENT_TIMEOUT 1 48 | #define SIGNAL_EVENT_KILLTHREAD 2 49 | 50 | #define BUFFSIZE 1000000 51 | 52 | #define PATH "/proc/asound/card1/stream0" 53 | 54 | extern "C" { 55 | #include 56 | #include "alsa_audio.h" 57 | #include "msm8960_use_cases.h" 58 | } 59 | 60 | #include 61 | 62 | namespace android_audio_legacy 63 | { 64 | using android::List; 65 | using android::Mutex; 66 | class AudioUsbALSA; 67 | 68 | class AudioUsbALSA 69 | { 70 | private: 71 | int mproxypfdPlayback; 72 | int musbpfdPlayback; 73 | int mnfdsPlayback; 74 | int mnfdsRecording; 75 | int mtimeOut; 76 | int mtimeOutRecording; 77 | struct pcm *mproxyRecordingHandle; 78 | struct pcm *musbRecordingHandle; 79 | struct pcm *mproxyPlaybackHandle; 80 | struct pcm *musbPlaybackHandle; 81 | u_int8_t *mdstUsb_addr; 82 | u_int8_t *msrcProxy_addr; 83 | bool mkillPlayBackThread; 84 | bool mkillRecordingThread; 85 | pthread_t mPlaybackUsb; 86 | pthread_t mRecordingUsb; 87 | snd_use_case_mgr_t *mUcMgr; 88 | 89 | //Helper functions 90 | struct pcm * configureDevice(unsigned flags, char* hw, int sampleRate, int channelCount, int periodSize, bool playback); 91 | status_t syncPtr(struct pcm *handle, bool *killThread); 92 | 93 | //playback 94 | void pollForProxyData(); 95 | void pollForUsbData(); 96 | 97 | //recording 98 | void pollForUsbDataForRecording(); 99 | void pollForProxyDataForRecording(); 100 | 101 | status_t startDevice(pcm *handle, bool *killThread); 102 | 103 | void PlaybackThreadEntry(); 104 | static void *PlaybackThreadWrapper(void *me); 105 | 106 | void RecordingThreadEntry(); 107 | static void *RecordingThreadWrapper(void *me); 108 | 109 | status_t setHardwareParams(pcm *local_handle, uint32_t sampleRate, uint32_t channels, int periodSize); 110 | 111 | status_t setSoftwareParams(pcm *pcm, bool playback); 112 | 113 | status_t closeDevice(pcm *handle); 114 | 115 | status_t getCap(char * type, int &channels, int &sampleRate); 116 | int getnumOfRates(char *rateStr); 117 | int mchannelsPlayback; 118 | int msampleRatePlayback; 119 | int mchannelsCapture; 120 | int msampleRateCapture; 121 | 122 | public: 123 | AudioUsbALSA(); 124 | virtual ~AudioUsbALSA(); 125 | 126 | void exitPlaybackThread(uint64_t writeVal); 127 | void exitRecordingThread(uint64_t writeVal); 128 | void setkillUsbRecordingThread(bool val); 129 | bool getkillUsbPlaybackThread() { 130 | return mkillPlayBackThread; 131 | } 132 | bool getkillUsbRecordingThread() { 133 | return mkillRecordingThread; 134 | } 135 | //Playback 136 | void startPlayback(); 137 | 138 | //Capture 139 | void startRecording(); 140 | }; 141 | 142 | }; // namespace android_audio_legacy 143 | #endif // ANDROID_AUDIO_USB_ALSA_H 144 | -------------------------------------------------------------------------------- /hal/audio_extn/ext_speaker.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "ext_speaker" 18 | /*#define LOG_NDEBUG 0*/ 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifdef __LP64__ 26 | #define LIB_SPEAKER_BUNDLE "/vendor/lib64/soundfx/libspeakerbundle.so" 27 | #else 28 | #define LIB_SPEAKER_BUNDLE "/vendor/lib/soundfx/libspeakerbundle.so" 29 | #endif 30 | 31 | typedef void (*set_mode_t)(int); 32 | typedef void (*set_speaker_on_t)(bool); 33 | typedef void (*set_earpiece_on_t)(bool); 34 | typedef void (*set_voice_vol_t)(float); 35 | 36 | struct speaker_data { 37 | struct audio_device *adev; 38 | void *speaker_bundle; 39 | set_mode_t set_mode; 40 | set_speaker_on_t set_speaker_on; 41 | set_earpiece_on_t set_earpiece_on; 42 | set_voice_vol_t set_voice_vol; 43 | }; 44 | 45 | static struct speaker_data* open_speaker_bundle() 46 | { 47 | struct speaker_data *sd = calloc(1, sizeof(struct speaker_data)); 48 | 49 | sd->speaker_bundle = dlopen(LIB_SPEAKER_BUNDLE, RTLD_NOW); 50 | if (sd->speaker_bundle == NULL) { 51 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_SPEAKER_BUNDLE); 52 | goto error; 53 | } else { 54 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_SPEAKER_BUNDLE); 55 | 56 | sd->set_mode = (set_mode_t)dlsym(sd->speaker_bundle, 57 | "set_mode"); 58 | if (sd->set_mode == NULL) { 59 | ALOGE("%s: dlsym error %s for set_mode", __func__, 60 | dlerror()); 61 | goto error; 62 | } 63 | sd->set_speaker_on = (set_speaker_on_t)dlsym(sd->speaker_bundle, 64 | "set_speaker_on"); 65 | if (sd->set_speaker_on == NULL) { 66 | ALOGE("%s: dlsym error %s for set_speaker_on", __func__, 67 | dlerror()); 68 | goto error; 69 | } 70 | sd->set_earpiece_on = (set_earpiece_on_t)dlsym(sd->speaker_bundle, 71 | "set_earpiece_on"); 72 | if (sd->set_earpiece_on == NULL) { 73 | ALOGE("%s: dlsym error %s for set_earpiece_on", __func__, 74 | dlerror()); 75 | goto error; 76 | } 77 | sd->set_voice_vol = (set_voice_vol_t)dlsym(sd->speaker_bundle, 78 | "set_voice_volume"); 79 | if (sd->set_voice_vol == NULL) { 80 | ALOGE("%s: dlsym error %s for set_voice_volume", 81 | __func__, dlerror()); 82 | goto error; 83 | } 84 | } 85 | return sd; 86 | 87 | error: 88 | free(sd); 89 | return 0; 90 | } 91 | 92 | static void close_speaker_bundle(struct speaker_data *sd) 93 | { 94 | if (sd != NULL) { 95 | dlclose(sd->speaker_bundle); 96 | free(sd); 97 | sd = NULL; 98 | } 99 | } 100 | 101 | void *audio_extn_extspk_init(struct audio_device *adev) 102 | { 103 | struct speaker_data *data = open_speaker_bundle(); 104 | 105 | if (data) 106 | data->adev = adev; 107 | 108 | return data; 109 | } 110 | 111 | void audio_extn_extspk_deinit(void *extn) 112 | { 113 | struct speaker_data *data = (struct speaker_data*)extn; 114 | close_speaker_bundle(data); 115 | } 116 | 117 | void audio_extn_extspk_update(void* extn) 118 | { 119 | struct speaker_data *data = (struct speaker_data*)extn; 120 | 121 | if (data) { 122 | bool speaker_on = false; 123 | bool earpiece_on = false; 124 | struct listnode *node; 125 | struct audio_usecase *usecase; 126 | list_for_each(node, &data->adev->usecase_list) { 127 | usecase = node_to_item(node, struct audio_usecase, list); 128 | if (usecase->devices & AUDIO_DEVICE_OUT_EARPIECE) { 129 | if(data->adev->snd_dev_ref_cnt[usecase->out_snd_device] != 0) { 130 | earpiece_on = true; 131 | } 132 | } 133 | if (usecase->devices & AUDIO_DEVICE_OUT_SPEAKER) { 134 | if(data->adev->snd_dev_ref_cnt[usecase->out_snd_device] != 0) { 135 | speaker_on = true; 136 | } 137 | } 138 | } 139 | data->set_earpiece_on(earpiece_on); 140 | data->set_speaker_on(speaker_on); 141 | } 142 | } 143 | 144 | void audio_extn_extspk_set_mode(void* extn, audio_mode_t mode) 145 | { 146 | struct speaker_data *data = (struct speaker_data*)extn; 147 | 148 | if (data) 149 | data->set_mode(mode); 150 | } 151 | 152 | void audio_extn_extspk_set_voice_vol(void* extn, float vol) 153 | { 154 | struct speaker_data *data = (struct speaker_data*)extn; 155 | 156 | if (data) 157 | data->set_voice_vol(vol); 158 | } 159 | -------------------------------------------------------------------------------- /hal/audio_extn/audio_extn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "audio_hw_extn" 18 | /*#define LOG_NDEBUG 0*/ 19 | #define LOG_NDDEBUG 0 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "audio_hw.h" 28 | #include "audio_extn.h" 29 | #include "platform.h" 30 | #include "platform_api.h" 31 | 32 | struct snd_card_split cur_snd_card_split = { 33 | .device = {0}, 34 | .snd_card = {0}, 35 | .form_factor = {0}, 36 | }; 37 | 38 | struct snd_card_split *audio_extn_get_snd_card_split() 39 | { 40 | return &cur_snd_card_split; 41 | } 42 | 43 | void audio_extn_set_snd_card_split(const char* in_snd_card_name) 44 | { 45 | /* sound card name follows below mentioned convention 46 | --
-snd-card 47 | parse target name, sound card name and form factor 48 | */ 49 | char *snd_card_name = strdup(in_snd_card_name); 50 | char *tmp = NULL; 51 | char *device = NULL; 52 | char *snd_card = NULL; 53 | char *form_factor = NULL; 54 | 55 | if (in_snd_card_name == NULL) { 56 | ALOGE("%s: snd_card_name passed is NULL", __func__); 57 | goto on_error; 58 | } 59 | 60 | device = strtok_r(snd_card_name, "-", &tmp); 61 | if (device == NULL) { 62 | ALOGE("%s: called on invalid snd card name", __func__); 63 | goto on_error; 64 | } 65 | strlcpy(cur_snd_card_split.device, device, HW_INFO_ARRAY_MAX_SIZE); 66 | 67 | snd_card = strtok_r(NULL, "-", &tmp); 68 | if (snd_card == NULL) { 69 | ALOGE("%s: called on invalid snd card name", __func__); 70 | goto on_error; 71 | } 72 | strlcpy(cur_snd_card_split.snd_card, snd_card, HW_INFO_ARRAY_MAX_SIZE); 73 | 74 | form_factor = strtok_r(NULL, "-", &tmp); 75 | if (form_factor == NULL) { 76 | ALOGE("%s: called on invalid snd card name", __func__); 77 | goto on_error; 78 | } 79 | strlcpy(cur_snd_card_split.form_factor, form_factor, HW_INFO_ARRAY_MAX_SIZE); 80 | 81 | ALOGI("%s: snd_card_name(%s) device(%s) snd_card(%s) form_factor(%s)", 82 | __func__, in_snd_card_name, device, snd_card, form_factor); 83 | 84 | on_error: 85 | if (snd_card_name) 86 | free(snd_card_name); 87 | } 88 | 89 | #ifdef KPI_OPTIMIZE_ENABLED 90 | typedef int (*perf_lock_acquire_t)(int, int, int*, int); 91 | typedef int (*perf_lock_release_t)(int); 92 | 93 | static void *qcopt_handle; 94 | static perf_lock_acquire_t perf_lock_acq; 95 | static perf_lock_release_t perf_lock_rel; 96 | 97 | static int perf_lock_handle; 98 | char opt_lib_path[PROPERTY_VALUE_MAX] = {0}; 99 | 100 | int perf_lock_opts[] = {0x101, 0x20E, 0x30E}; 101 | 102 | int audio_extn_perf_lock_init(void) 103 | { 104 | int ret = 0; 105 | if (qcopt_handle == NULL) { 106 | if (property_get("ro.vendor.extension_library", 107 | opt_lib_path, NULL) <= 0) { 108 | ALOGE("%s: Failed getting perf property", __func__); 109 | ret = -EINVAL; 110 | goto err; 111 | } 112 | if ((qcopt_handle = dlopen(opt_lib_path, RTLD_NOW)) == NULL) { 113 | ALOGE("%s: Failed to open perf handle", __func__); 114 | ret = -EINVAL; 115 | goto err; 116 | } else { 117 | perf_lock_acq = (perf_lock_acquire_t)dlsym(qcopt_handle, 118 | "perf_lock_acq"); 119 | if (perf_lock_acq == NULL) { 120 | ALOGE("%s: Perf lock Acquire NULL", __func__); 121 | dlclose(qcopt_handle); 122 | qcopt_handle = NULL; 123 | ret = -EINVAL; 124 | goto err; 125 | } 126 | perf_lock_rel = (perf_lock_release_t)dlsym(qcopt_handle, 127 | "perf_lock_rel"); 128 | if (perf_lock_rel == NULL) { 129 | ALOGE("%s: Perf lock Release NULL", __func__); 130 | dlclose(qcopt_handle); 131 | qcopt_handle = NULL; 132 | ret = -EINVAL; 133 | goto err; 134 | } 135 | ALOGD("%s: Perf lock handles Success", __func__); 136 | } 137 | } 138 | err: 139 | return ret; 140 | } 141 | 142 | void audio_extn_perf_lock_acquire(void) 143 | { 144 | if (perf_lock_acq) { 145 | perf_lock_handle = perf_lock_acq(perf_lock_handle, 0, perf_lock_opts, 3); 146 | ALOGV("%s: Perf lock acquired", __func__); 147 | } else { 148 | ALOGE("%s: Perf lock acquire error", __func__); 149 | } 150 | } 151 | 152 | void audio_extn_perf_lock_release(void) 153 | { 154 | if (perf_lock_rel && perf_lock_handle) { 155 | perf_lock_rel(perf_lock_handle); 156 | perf_lock_handle = 0; 157 | ALOGV("%s: Perf lock released", __func__); 158 | } else { 159 | ALOGE("%s: Perf lock release error", __func__); 160 | } 161 | } 162 | #endif /* KPI_OPTIMIZE_ENABLED */ 163 | -------------------------------------------------------------------------------- /hal/msm8974/hw_info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "hardware_info" 18 | /*#define LOG_NDEBUG 0*/ 19 | #define LOG_NDDEBUG 0 20 | 21 | #include 22 | #include 23 | #include "audio_hw.h" 24 | #include "platform.h" 25 | #include "audio_extn.h" 26 | 27 | struct hardware_info { 28 | char name[HW_INFO_ARRAY_MAX_SIZE]; 29 | char type[HW_INFO_ARRAY_MAX_SIZE]; 30 | /* variables for handling target variants */ 31 | uint32_t num_snd_devices; 32 | char dev_extn[HW_INFO_ARRAY_MAX_SIZE]; 33 | snd_device_t *snd_devices; 34 | }; 35 | 36 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 37 | 38 | 39 | static const snd_device_t tasha_db_variant_devices[] = { 40 | SND_DEVICE_OUT_SPEAKER 41 | }; 42 | 43 | static const snd_device_t tasha_fluid_variant_devices[] = { 44 | SND_DEVICE_OUT_SPEAKER, 45 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 46 | SND_DEVICE_OUT_VOICE_SPEAKER, 47 | SND_DEVICE_OUT_SPEAKER_AND_HDMI, 48 | SND_DEVICE_OUT_SPEAKER_PROTECTED, 49 | SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED, 50 | }; 51 | 52 | static const snd_device_t tasha_liquid_variant_devices[] = { 53 | SND_DEVICE_OUT_SPEAKER, 54 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 55 | SND_DEVICE_IN_SPEAKER_MIC, 56 | SND_DEVICE_IN_HEADSET_MIC, 57 | SND_DEVICE_IN_VOICE_DMIC, 58 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC, 59 | SND_DEVICE_IN_VOICE_REC_DMIC_STEREO, 60 | SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE, 61 | SND_DEVICE_IN_QUAD_MIC, 62 | }; 63 | 64 | static void update_hardware_info_8996(struct hardware_info *hw_info) 65 | { 66 | struct snd_card_split *tmp_handle = audio_extn_get_snd_card_split(); 67 | ALOGV("%s: device %s snd_card %s form_factor %s", 68 | __func__, tmp_handle->device, tmp_handle->snd_card, tmp_handle->form_factor); 69 | 70 | strlcpy(hw_info->name, tmp_handle->device, sizeof(hw_info->name)); 71 | snprintf(hw_info->type, sizeof(hw_info->type), " %s", tmp_handle->form_factor); 72 | snprintf(hw_info->dev_extn, sizeof(hw_info->dev_extn), "-%s", tmp_handle->form_factor); 73 | 74 | if (!strncmp(tmp_handle->form_factor, "fluid", sizeof("fluid"))) { 75 | hw_info->snd_devices = (snd_device_t *)tasha_fluid_variant_devices; 76 | hw_info->num_snd_devices = ARRAY_SIZE(tasha_fluid_variant_devices); 77 | } else if (!strncmp(tmp_handle->form_factor, "liquid", sizeof("liquid"))) { 78 | hw_info->snd_devices = (snd_device_t *)tasha_liquid_variant_devices; 79 | hw_info->num_snd_devices = ARRAY_SIZE(tasha_liquid_variant_devices); 80 | } else if (!strncmp(tmp_handle->form_factor, "db", sizeof("db"))) { 81 | hw_info->snd_devices = (snd_device_t *)tasha_db_variant_devices; 82 | hw_info->num_snd_devices = ARRAY_SIZE(tasha_db_variant_devices); 83 | } else { 84 | ALOGW("%s: %s form factor doesnt need mixer path over ride", __func__, tmp_handle->form_factor); 85 | } 86 | 87 | ALOGV("name %s type %s dev_extn %s", hw_info->name, hw_info->type, hw_info->dev_extn); 88 | } 89 | 90 | 91 | void *hw_info_init(const char *snd_card_name) 92 | { 93 | struct hardware_info *hw_info = NULL; 94 | bool hw_supported = false; 95 | 96 | if (strstr(snd_card_name, "msm8996")) { 97 | ALOGD("8996 - variant soundcard"); 98 | hw_supported = true; 99 | } else { 100 | ALOGE("%s: Unsupported target %s:",__func__, snd_card_name); 101 | } 102 | 103 | if (hw_supported) { 104 | hw_info = malloc(sizeof(struct hardware_info)); 105 | if (!hw_info) { 106 | ALOGE("failed to allocate mem for hardware info"); 107 | goto on_finish; 108 | } 109 | 110 | hw_info->snd_devices = NULL; 111 | hw_info->num_snd_devices = 0; 112 | strlcpy(hw_info->dev_extn, "", sizeof(hw_info->dev_extn)); 113 | strlcpy(hw_info->type, "", sizeof(hw_info->type)); 114 | strlcpy(hw_info->name, "", sizeof(hw_info->name)); 115 | update_hardware_info_8996(hw_info); 116 | } 117 | 118 | on_finish: 119 | return hw_info; 120 | } 121 | 122 | void hw_info_deinit(void *hw_info) 123 | { 124 | free(hw_info); 125 | } 126 | 127 | void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device, 128 | char *device_name) 129 | { 130 | struct hardware_info *my_data = (struct hardware_info*) hw_info; 131 | uint32_t i = 0; 132 | 133 | if (my_data == NULL) 134 | return; 135 | 136 | snd_device_t *snd_devices = 137 | (snd_device_t *) my_data->snd_devices; 138 | 139 | if (snd_devices != NULL) { 140 | for (i = 0; i < my_data->num_snd_devices; i++) { 141 | if (snd_device == (snd_device_t)snd_devices[i]) { 142 | ALOGV("extract dev_extn device %d, device_name %s extn = %s ", 143 | (snd_device_t)snd_devices[i], device_name, my_data->dev_extn); 144 | CHECK(strlcat(device_name, my_data->dev_extn, 145 | DEVICE_NAME_MAX_SIZE) < DEVICE_NAME_MAX_SIZE); 146 | break; 147 | } 148 | } 149 | } 150 | ALOGD("%s : device_name = %s", __func__,device_name); 151 | } 152 | -------------------------------------------------------------------------------- /hal/msm8960/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef QCOM_AUDIO_PLATFORM_H 18 | #define QCOM_AUDIO_PLATFORM_H 19 | 20 | /* 21 | * Below are the devices for which is back end is same, SLIMBUS_0_RX. 22 | * All these devices are handled by the internal HW codec. We can 23 | * enable any one of these devices at any time 24 | */ 25 | #define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \ 26 | (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \ 27 | AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE) 28 | 29 | /* Sound devices specific to the platform 30 | * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound 31 | * devices to enable corresponding mixer paths 32 | */ 33 | enum { 34 | SND_DEVICE_NONE = 0, 35 | 36 | /* Playback devices */ 37 | SND_DEVICE_MIN, 38 | SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN, 39 | SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN, 40 | SND_DEVICE_OUT_SPEAKER, 41 | SND_DEVICE_OUT_SPEAKER_REVERSE, 42 | SND_DEVICE_OUT_SPEAKER_SAFE, 43 | SND_DEVICE_OUT_HEADPHONES, 44 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 45 | SND_DEVICE_OUT_VOICE_SPEAKER, 46 | SND_DEVICE_OUT_VOICE_HEADPHONES, 47 | SND_DEVICE_OUT_VOICE_HEADSET, 48 | SND_DEVICE_OUT_HDMI, 49 | SND_DEVICE_OUT_SPEAKER_AND_HDMI, 50 | SND_DEVICE_OUT_BT_SCO, 51 | SND_DEVICE_OUT_BT_SCO_WB, 52 | SND_DEVICE_OUT_BT_A2DP, 53 | SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP, 54 | SND_DEVICE_OUT_VOICE_HANDSET_TMUS, 55 | SND_DEVICE_OUT_VOICE_HANDSET, 56 | SND_DEVICE_OUT_VOICE_HAC_HANDSET, 57 | SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES, 58 | SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES, 59 | SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET, 60 | SND_DEVICE_OUT_USB_HEADSET, 61 | SND_DEVICE_OUT_USB_HEADPHONES, 62 | SND_DEVICE_OUT_VOICE_USB_HEADSET, 63 | SND_DEVICE_OUT_VOICE_USB_HEADPHONES, 64 | SND_DEVICE_OUT_END, 65 | 66 | /* 67 | * Note: IN_BEGIN should be same as OUT_END because total number of devices 68 | * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices. 69 | */ 70 | /* Capture devices */ 71 | SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END, 72 | SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN, 73 | SND_DEVICE_IN_SPEAKER_MIC, 74 | SND_DEVICE_IN_HEADSET_MIC, 75 | SND_DEVICE_IN_HANDSET_MIC_AEC, 76 | SND_DEVICE_IN_SPEAKER_MIC_AEC, 77 | SND_DEVICE_IN_HEADSET_MIC_AEC, 78 | SND_DEVICE_IN_VOICE_SPEAKER_MIC, 79 | SND_DEVICE_IN_VOICE_HEADSET_MIC, 80 | SND_DEVICE_IN_HDMI_MIC, 81 | SND_DEVICE_IN_BT_SCO_MIC, 82 | SND_DEVICE_IN_BT_SCO_MIC_WB, 83 | SND_DEVICE_IN_CAMCORDER_MIC, 84 | SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, 85 | SND_DEVICE_IN_VOICE_DMIC_EF, 86 | SND_DEVICE_IN_VOICE_DMIC_BS, 87 | SND_DEVICE_IN_VOICE_DMIC_EF_TMUS, 88 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF, 89 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS, 90 | SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC, 91 | SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC, 92 | SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC, 93 | SND_DEVICE_IN_VOICE_REC_MIC, 94 | SND_DEVICE_IN_VOICE_REC_DMIC_EF, 95 | SND_DEVICE_IN_VOICE_REC_DMIC_BS, 96 | SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE, 97 | SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE, 98 | SND_DEVICE_IN_END, 99 | 100 | SND_DEVICE_MAX = SND_DEVICE_IN_END, 101 | 102 | }; 103 | 104 | #define MIXER_CARD 0 105 | #define SOUND_CARD 0 106 | #define MIXER_PATH_MAX_LENGTH 100 107 | #define DEFAULT_OUTPUT_SAMPLING_RATE 48000 108 | #define DEFAULT_INPUT_SAMPLING_RATE 48000 109 | 110 | /* 111 | * tinyAlsa library interprets period size as number of frames 112 | * one frame = channel_count * sizeof (pcm sample) 113 | * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes 114 | * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes 115 | * We should take care of returning proper size when AudioFlinger queries for 116 | * the buffer size of an input/output stream 117 | */ 118 | #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960 119 | #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 8 120 | #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240 121 | #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2 122 | 123 | #define HDMI_MULTI_PERIOD_SIZE 336 124 | #define HDMI_MULTI_PERIOD_COUNT 8 125 | #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6 126 | #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2) 127 | 128 | #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 129 | #define AUDIO_CAPTURE_PERIOD_COUNT 2 130 | 131 | #define VOIP_CAPTURE_PERIOD_DURATION_MSEC 20 132 | #define VOIP_CAPTURE_PERIOD_COUNT 2 133 | 134 | #define VOIP_PLAYBACK_PERIOD_DURATION_MSEC 20 135 | #define VOIP_PLAYBACK_PERIOD_COUNT 2 136 | 137 | #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 138 | #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 139 | #define LOW_LATENCY_CAPTURE_USE_CASE 0 140 | 141 | #define AFE_PROXY_PLAYBACK_PCM_DEVICE 7 142 | #define AFE_PROXY_RECORD_PCM_DEVICE 8 143 | 144 | #define HFP_ASM_RX_TX 18 145 | 146 | #define PLATFORM_INFO_XML_PATH "audio_platform_info.xml" 147 | #define PLATFORM_INFO_XML_BASE_STRING "audio_platform_info" 148 | 149 | #define DEVICE_NAME_MAX_SIZE 128 150 | 151 | #define AUDIO_MAKE_STRING_FROM_ENUM(X) { #X, X } 152 | 153 | 154 | #endif // QCOM_AUDIO_PLATFORM_H 155 | -------------------------------------------------------------------------------- /hal/acdb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "audio_hw_acdb" 18 | //#define LOG_NDEBUG 0 19 | #define LOG_NDDEBUG 0 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "acdb.h" 30 | #include 31 | 32 | #define PLATFORM_CONFIG_KEY_SOUNDCARD_NAME "snd_card_name" 33 | 34 | int acdb_init(int snd_card_num) 35 | { 36 | 37 | int result = -1; 38 | char *cvd_version = NULL; 39 | 40 | char *snd_card_name = NULL; 41 | struct mixer *mixer = NULL; 42 | struct acdb_platform_data *my_data = NULL; 43 | 44 | if(snd_card_num < 0) { 45 | ALOGE("invalid sound card number"); 46 | return result; 47 | } 48 | 49 | mixer = mixer_open(snd_card_num); 50 | if (!mixer) { 51 | ALOGE("%s: Unable to open the mixer card: %d", __func__, 52 | snd_card_num); 53 | goto cleanup; 54 | } 55 | 56 | my_data = calloc(1, sizeof(struct acdb_platform_data)); 57 | if (!my_data) { 58 | ALOGE("failed to allocate acdb platform data"); 59 | goto cleanup; 60 | } 61 | 62 | list_init(&my_data->acdb_meta_key_list); 63 | 64 | my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); 65 | if (my_data->acdb_handle == NULL) { 66 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); 67 | goto cleanup; 68 | } 69 | 70 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); 71 | 72 | my_data->acdb_init_v3 = (acdb_init_v3_t)dlsym(my_data->acdb_handle, 73 | "acdb_loader_init_v3"); 74 | if (my_data->acdb_init_v3 == NULL) 75 | ALOGE("%s: dlsym error %s for acdb_loader_init_v3", __func__, dlerror()); 76 | 77 | my_data->acdb_init_v2 = (acdb_init_v2_cvd_t)dlsym(my_data->acdb_handle, 78 | "acdb_loader_init_v2"); 79 | if (my_data->acdb_init_v2 == NULL) 80 | ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); 81 | 82 | my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, 83 | "acdb_loader_init_ACDB"); 84 | if (my_data->acdb_init == NULL && my_data->acdb_init_v2 == NULL 85 | && my_data->acdb_init_v3 == NULL) { 86 | ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); 87 | goto cleanup; 88 | } 89 | 90 | /* Get CVD version */ 91 | cvd_version = calloc(1, MAX_CVD_VERSION_STRING_SIZE); 92 | if (!cvd_version) { 93 | ALOGE("%s: Failed to allocate cvd version", __func__); 94 | goto cleanup; 95 | } else { 96 | struct mixer_ctl *ctl = NULL; 97 | int count = 0; 98 | 99 | ctl = mixer_get_ctl_by_name(mixer, CVD_VERSION_MIXER_CTL); 100 | if (!ctl) { 101 | ALOGE("%s: Could not get ctl for mixer cmd - %s", __func__, CVD_VERSION_MIXER_CTL); 102 | goto cleanup; 103 | } 104 | mixer_ctl_update(ctl); 105 | 106 | count = mixer_ctl_get_num_values(ctl); 107 | if (count > MAX_CVD_VERSION_STRING_SIZE) 108 | count = MAX_CVD_VERSION_STRING_SIZE; 109 | 110 | result = mixer_ctl_get_array(ctl, cvd_version, count); 111 | if (result != 0) { 112 | ALOGE("%s: ERROR! mixer_ctl_get_array() failed to get CVD Version", __func__); 113 | goto cleanup; 114 | } 115 | } 116 | 117 | /* Get Sound card name */ 118 | snd_card_name = strdup(mixer_get_name(mixer)); 119 | if (!snd_card_name) { 120 | ALOGE("failed to allocate memory for snd_card_name"); 121 | result = -1; 122 | goto cleanup; 123 | } 124 | 125 | if (my_data->acdb_init_v3) 126 | result = my_data->acdb_init_v3(snd_card_name, cvd_version, 127 | &my_data->acdb_meta_key_list); 128 | else if (my_data->acdb_init_v2) 129 | result = my_data->acdb_init_v2(snd_card_name, cvd_version, 0); 130 | else 131 | result = my_data->acdb_init(); 132 | 133 | cleanup: 134 | if (NULL != my_data) { 135 | if (my_data->acdb_handle) 136 | dlclose(my_data->acdb_handle); 137 | 138 | struct listnode *node; 139 | struct meta_key_list *key_info; 140 | list_for_each(node, &my_data->acdb_meta_key_list) { 141 | key_info = node_to_item(node, struct meta_key_list, list); 142 | free(key_info); 143 | } 144 | free(my_data); 145 | } 146 | 147 | mixer_close(mixer); 148 | free(cvd_version); 149 | free(snd_card_name); 150 | 151 | return result; 152 | } 153 | 154 | int acdb_set_parameters(void *platform, struct str_parms *parms) 155 | { 156 | struct acdb_platform_data *my_data = (struct acdb_platform_data *)platform; 157 | char value[128]; 158 | char *kv_pairs = str_parms_to_str(parms); 159 | int ret = 0; 160 | 161 | if (kv_pairs == NULL) { 162 | ret = -EINVAL; 163 | ALOGE("%s: key-value pair is NULL",__func__); 164 | goto done; 165 | } 166 | 167 | ret = str_parms_get_str(parms, PLATFORM_CONFIG_KEY_SOUNDCARD_NAME, 168 | value, sizeof(value)); 169 | if (ret >= 0) { 170 | str_parms_del(parms, PLATFORM_CONFIG_KEY_SOUNDCARD_NAME); 171 | my_data->snd_card_name = strdup(value); 172 | ALOGV("%s: sound card name %s", __func__, my_data->snd_card_name); 173 | } 174 | 175 | done: 176 | free(kv_pairs); 177 | 178 | return ret; 179 | } 180 | -------------------------------------------------------------------------------- /legacy/alsa_sound/AudioPolicyManagerALSA.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #define LOG_TAG "AudioPolicyManagerALSA" 19 | //#define LOG_NDEBUG 0 20 | #define LOG_NDDEBUG 0 21 | #include 22 | 23 | #include "AudioPolicyManagerALSA.h" 24 | #include 25 | 26 | namespace android_audio_legacy { 27 | 28 | // ---------------------------------------------------------------------------- 29 | // AudioPolicyManagerALSA 30 | // ---------------------------------------------------------------------------- 31 | 32 | //Compiling error seen if AudioParamer doesn't exist in this file 33 | 34 | AudioParameter param; 35 | 36 | // --- class factory 37 | 38 | 39 | extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface) 40 | { 41 | return new AudioPolicyManager(clientInterface); 42 | } 43 | 44 | extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface) 45 | { 46 | delete interface; 47 | } 48 | 49 | void AudioPolicyManager::setPhoneState(int state) { 50 | ALOGV("setPhoneState() state %d", state); 51 | audio_devices_t newDevice = AUDIO_DEVICE_NONE; 52 | if (state < 0 || state >= AudioSystem::NUM_MODES) { 53 | ALOGW("setPhoneState() invalid state %d", state); 54 | return; 55 | } 56 | 57 | if (state == mPhoneState) { 58 | ALOGW("setPhoneState() setting same state %d", state); 59 | return; 60 | } 61 | 62 | // if leaving call state, handle special case of active streams 63 | // pertaining to sonification strategy see handleIncallSonification() 64 | if (isInCall()) { 65 | ALOGV("setPhoneState() in call state management: new state is %d", state); 66 | for (int stream = 0; stream < AudioSystem::NUM_STREAM_TYPES; stream++) { 67 | handleIncallSonification(stream, false, true); 68 | } 69 | } 70 | 71 | // store previous phone state for management of sonification strategy below 72 | int oldState = mPhoneState; 73 | mPhoneState = state; 74 | bool force = false; 75 | 76 | // are we entering or starting a call 77 | if (!isStateInCall(oldState) && isStateInCall(state)) { 78 | ALOGV(" Entering call in setPhoneState()"); 79 | // force routing command to audio hardware when starting a call 80 | // even if no device change is needed 81 | force = true; 82 | } else if (isStateInCall(oldState) && !isStateInCall(state)) { 83 | ALOGV(" Exiting call in setPhoneState()"); 84 | // force routing command to audio hardware when exiting a call 85 | // even if no device change is needed 86 | force = true; 87 | } else if (isStateInCall(state) && (state != oldState)) { 88 | ALOGV(" Switching between telephony and VoIP in setPhoneState()"); 89 | // force routing command to audio hardware when switching between telephony and VoIP 90 | // even if no device change is needed 91 | force = true; 92 | } 93 | 94 | // check for device and output changes triggered by new phone state 95 | newDevice = getNewDevice(mPrimaryOutput, false /*fromCache*/); 96 | checkA2dpSuspend(); 97 | checkOutputForAllStrategies(); 98 | updateDevicesAndOutputs(); 99 | 100 | AudioOutputDescriptor *hwOutputDesc = mOutputs.valueFor(mPrimaryOutput); 101 | 102 | // force routing command to audio hardware when ending call 103 | // even if no device change is needed 104 | if (isStateInCall(oldState) && newDevice == AUDIO_DEVICE_NONE) { 105 | newDevice = hwOutputDesc->device(); 106 | } 107 | 108 | // when changing from ring tone to in call mode, mute the ringing tone 109 | // immediately and delay the route change to avoid sending the ring tone 110 | // tail into the earpiece or headset. 111 | int delayMs = 0; 112 | if (isStateInCall(state) && oldState == AudioSystem::MODE_RINGTONE) { 113 | // delay the device change command by twice the output latency to have some margin 114 | // and be sure that audio buffers not yet affected by the mute are out when 115 | // we actually apply the route change 116 | delayMs = hwOutputDesc->mLatency*2; 117 | setStreamMute(AudioSystem::RING, true, mPrimaryOutput); 118 | } 119 | 120 | if (isStateInCall(state)) { 121 | for (size_t i = 0; i < mOutputs.size(); i++) { 122 | AudioOutputDescriptor *desc = mOutputs.valueAt(i); 123 | //take the biggest latency for all outputs 124 | if (delayMs < desc->mLatency*2) { 125 | delayMs = desc->mLatency*2; 126 | } 127 | //mute STRATEGY_MEDIA on all outputs 128 | if (desc->strategyRefCount(STRATEGY_MEDIA) != 0) { 129 | setStrategyMute(STRATEGY_MEDIA, true, mOutputs.keyAt(i)); 130 | setStrategyMute(STRATEGY_MEDIA, false, mOutputs.keyAt(i), MUTE_TIME_MS, 131 | getDeviceForStrategy(STRATEGY_MEDIA, true /*fromCache*/)); 132 | } 133 | } 134 | } 135 | 136 | // Ignore the delay to enable voice call on this target as the enabling the 137 | // voice call has enough delay to make sure the ringtone audio completely 138 | // played out 139 | if (state == AudioSystem::MODE_IN_CALL && oldState == AudioSystem::MODE_RINGTONE) { 140 | delayMs = 40; 141 | } 142 | 143 | // change routing is necessary 144 | setOutputDevice(mPrimaryOutput, newDevice, force, delayMs); 145 | 146 | // if entering in call state, handle special case of active streams 147 | // pertaining to sonification strategy see handleIncallSonification() 148 | if (isStateInCall(state)) { 149 | ALOGV("setPhoneState() in call state management: new state is %d", state); 150 | // unmute the ringing tone after a sufficient delay if it was muted before 151 | // setting output device above 152 | if (oldState == AudioSystem::MODE_RINGTONE) { 153 | setStreamMute(AudioSystem::RING, false, mPrimaryOutput, MUTE_TIME_MS); 154 | } 155 | for (int stream = 0; stream < AudioSystem::NUM_STREAM_TYPES; stream++) { 156 | handleIncallSonification(stream, true, true); 157 | } 158 | } 159 | 160 | // Flag that ringtone volume must be limited to music volume until we exit MODE_RINGTONE 161 | if (state == AudioSystem::MODE_RINGTONE && 162 | isStreamActive(AudioSystem::MUSIC, SONIFICATION_HEADSET_MUSIC_DELAY)) { 163 | mLimitRingtoneVolume = true; 164 | } else { 165 | mLimitRingtoneVolume = false; 166 | } 167 | } 168 | 169 | }; // namespace androidi_audio_legacy 170 | -------------------------------------------------------------------------------- /post_proc/effect_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFFLOAD_EFFECT_API_H_ 18 | #define OFFLOAD_EFFECT_API_H_ 19 | 20 | int offload_update_mixer_and_effects_ctl(int card, int device_id, 21 | struct mixer *mixer, 22 | struct mixer_ctl *ctl); 23 | void offload_close_mixer(struct mixer *mixer); 24 | 25 | #define OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG (1 << 0) 26 | #define OFFLOAD_SEND_BASSBOOST_STRENGTH \ 27 | (OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG << 1) 28 | #define OFFLOAD_SEND_BASSBOOST_MODE \ 29 | (OFFLOAD_SEND_BASSBOOST_STRENGTH << 1) 30 | void offload_bassboost_set_device(struct bass_boost_params *bassboost, 31 | uint32_t device); 32 | void offload_bassboost_set_enable_flag(struct bass_boost_params *bassboost, 33 | bool enable); 34 | int offload_bassboost_get_enable_flag(struct bass_boost_params *bassboost); 35 | void offload_bassboost_set_strength(struct bass_boost_params *bassboost, 36 | int strength); 37 | void offload_bassboost_set_mode(struct bass_boost_params *bassboost, 38 | int mode); 39 | int offload_bassboost_send_params(struct mixer_ctl *ctl, 40 | struct bass_boost_params *bassboost, 41 | unsigned param_send_flags); 42 | 43 | #define OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG (1 << 0) 44 | #define OFFLOAD_SEND_VIRTUALIZER_STRENGTH \ 45 | (OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG << 1) 46 | #define OFFLOAD_SEND_VIRTUALIZER_OUT_TYPE \ 47 | (OFFLOAD_SEND_VIRTUALIZER_STRENGTH << 1) 48 | #define OFFLOAD_SEND_VIRTUALIZER_GAIN_ADJUST \ 49 | (OFFLOAD_SEND_VIRTUALIZER_OUT_TYPE << 1) 50 | void offload_virtualizer_set_device(struct virtualizer_params *virtualizer, 51 | uint32_t device); 52 | void offload_virtualizer_set_enable_flag(struct virtualizer_params *virtualizer, 53 | bool enable); 54 | int offload_virtualizer_get_enable_flag(struct virtualizer_params *virtualizer); 55 | void offload_virtualizer_set_strength(struct virtualizer_params *virtualizer, 56 | int strength); 57 | void offload_virtualizer_set_out_type(struct virtualizer_params *virtualizer, 58 | int out_type); 59 | void offload_virtualizer_set_gain_adjust(struct virtualizer_params *virtualizer, 60 | int gain_adjust); 61 | int offload_virtualizer_send_params(struct mixer_ctl *ctl, 62 | struct virtualizer_params *virtualizer, 63 | unsigned param_send_flags); 64 | 65 | #define OFFLOAD_SEND_EQ_ENABLE_FLAG (1 << 0) 66 | #define OFFLOAD_SEND_EQ_PRESET \ 67 | (OFFLOAD_SEND_EQ_ENABLE_FLAG << 1) 68 | #define OFFLOAD_SEND_EQ_BANDS_LEVEL \ 69 | (OFFLOAD_SEND_EQ_PRESET << 1) 70 | void offload_eq_set_device(struct eq_params *eq, uint32_t device); 71 | void offload_eq_set_enable_flag(struct eq_params *eq, bool enable); 72 | int offload_eq_get_enable_flag(struct eq_params *eq); 73 | void offload_eq_set_preset(struct eq_params *eq, int preset); 74 | void offload_eq_set_bands_level(struct eq_params *eq, int num_bands, 75 | const uint16_t *band_freq_list, 76 | int *band_gain_list); 77 | int offload_eq_send_params(struct mixer_ctl *ctl, struct eq_params *eq, 78 | unsigned param_send_flags); 79 | 80 | #define OFFLOAD_SEND_REVERB_ENABLE_FLAG (1 << 0) 81 | #define OFFLOAD_SEND_REVERB_MODE \ 82 | (OFFLOAD_SEND_REVERB_ENABLE_FLAG << 1) 83 | #define OFFLOAD_SEND_REVERB_PRESET \ 84 | (OFFLOAD_SEND_REVERB_MODE << 1) 85 | #define OFFLOAD_SEND_REVERB_WET_MIX \ 86 | (OFFLOAD_SEND_REVERB_PRESET << 1) 87 | #define OFFLOAD_SEND_REVERB_GAIN_ADJUST \ 88 | (OFFLOAD_SEND_REVERB_WET_MIX << 1) 89 | #define OFFLOAD_SEND_REVERB_ROOM_LEVEL \ 90 | (OFFLOAD_SEND_REVERB_GAIN_ADJUST << 1) 91 | #define OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL \ 92 | (OFFLOAD_SEND_REVERB_ROOM_LEVEL << 1) 93 | #define OFFLOAD_SEND_REVERB_DECAY_TIME \ 94 | (OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL << 1) 95 | #define OFFLOAD_SEND_REVERB_DECAY_HF_RATIO \ 96 | (OFFLOAD_SEND_REVERB_DECAY_TIME << 1) 97 | #define OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL \ 98 | (OFFLOAD_SEND_REVERB_DECAY_HF_RATIO << 1) 99 | #define OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY \ 100 | (OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL << 1) 101 | #define OFFLOAD_SEND_REVERB_LEVEL \ 102 | (OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY << 1) 103 | #define OFFLOAD_SEND_REVERB_DELAY \ 104 | (OFFLOAD_SEND_REVERB_LEVEL << 1) 105 | #define OFFLOAD_SEND_REVERB_DIFFUSION \ 106 | (OFFLOAD_SEND_REVERB_DELAY << 1) 107 | #define OFFLOAD_SEND_REVERB_DENSITY \ 108 | (OFFLOAD_SEND_REVERB_DIFFUSION << 1) 109 | void offload_reverb_set_device(struct reverb_params *reverb, uint32_t device); 110 | void offload_reverb_set_enable_flag(struct reverb_params *reverb, bool enable); 111 | int offload_reverb_get_enable_flag(struct reverb_params *reverb); 112 | void offload_reverb_set_mode(struct reverb_params *reverb, int mode); 113 | void offload_reverb_set_preset(struct reverb_params *reverb, int preset); 114 | void offload_reverb_set_wet_mix(struct reverb_params *reverb, int wet_mix); 115 | void offload_reverb_set_gain_adjust(struct reverb_params *reverb, 116 | int gain_adjust); 117 | void offload_reverb_set_room_level(struct reverb_params *reverb, 118 | int room_level); 119 | void offload_reverb_set_room_hf_level(struct reverb_params *reverb, 120 | int room_hf_level); 121 | void offload_reverb_set_decay_time(struct reverb_params *reverb, 122 | int decay_time); 123 | void offload_reverb_set_decay_hf_ratio(struct reverb_params *reverb, 124 | int decay_hf_ratio); 125 | void offload_reverb_set_reflections_level(struct reverb_params *reverb, 126 | int reflections_level); 127 | void offload_reverb_set_reflections_delay(struct reverb_params *reverb, 128 | int reflections_delay); 129 | void offload_reverb_set_reverb_level(struct reverb_params *reverb, 130 | int reverb_level); 131 | void offload_reverb_set_delay(struct reverb_params *reverb, int delay); 132 | void offload_reverb_set_diffusion(struct reverb_params *reverb, int diffusion); 133 | void offload_reverb_set_density(struct reverb_params *reverb, int density); 134 | int offload_reverb_send_params(struct mixer_ctl *ctl, 135 | struct reverb_params *reverb, 136 | unsigned param_send_flags); 137 | 138 | #endif /*OFFLOAD_EFFECT_API_H_*/ 139 | -------------------------------------------------------------------------------- /hal/Android.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true) 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_ARM_MODE := arm 8 | 9 | AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM) 10 | ifneq ($(filter msm8960,$(TARGET_BOARD_PLATFORM)),) 11 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="2" 12 | endif 13 | ifneq ($(filter msm8974 msm8226 msm8084 msm8992 msm8994 msm8996 msm8998 sdm845 sdm710 msmnile,$(TARGET_BOARD_PLATFORM)),) 14 | # B-family platform uses msm8974 code base 15 | AUDIO_PLATFORM = msm8974 16 | ifneq ($(filter msm8974,$(TARGET_BOARD_PLATFORM)),) 17 | LOCAL_CFLAGS := -DPLATFORM_MSM8974 18 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="2" 19 | endif 20 | ifneq ($(filter msm8226,$(TARGET_BOARD_PLATFORM)),) 21 | LOCAL_CFLAGS := -DPLATFORM_MSM8x26 22 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="2" 23 | endif 24 | ifneq ($(filter msm8084,$(TARGET_BOARD_PLATFORM)),) 25 | LOCAL_CFLAGS := -DPLATFORM_MSM8084 26 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="2" 27 | endif 28 | ifneq ($(filter msm8992,$(TARGET_BOARD_PLATFORM)),) 29 | LOCAL_CFLAGS := -DPLATFORM_MSM8994 30 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 31 | LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED 32 | endif 33 | ifneq ($(filter msm8994,$(TARGET_BOARD_PLATFORM)),) 34 | LOCAL_CFLAGS := -DPLATFORM_MSM8994 35 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 36 | LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED 37 | endif 38 | ifneq ($(filter msm8996,$(TARGET_BOARD_PLATFORM)),) 39 | LOCAL_CFLAGS := -DPLATFORM_MSM8996 40 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 41 | LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED 42 | LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED 43 | MULTIPLE_HW_VARIANTS_ENABLED := true 44 | endif 45 | ifneq ($(filter msm8998,$(TARGET_BOARD_PLATFORM)),) 46 | LOCAL_CFLAGS := -DPLATFORM_MSM8998 47 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 48 | LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED 49 | MULTIPLE_HW_VARIANTS_ENABLED := true 50 | endif 51 | ifneq ($(filter sdm845,$(TARGET_BOARD_PLATFORM)),) 52 | LOCAL_CFLAGS := -DPLATFORM_SDM845 53 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 54 | LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED 55 | LOCAL_CFLAGS += -DINCALL_STEREO_CAPTURE_ENABLED 56 | MULTIPLE_HW_VARIANTS_ENABLED := true 57 | endif 58 | ifneq ($(filter sdm710,$(TARGET_BOARD_PLATFORM)),) 59 | LOCAL_CFLAGS := -DPLATFORM_SDM710 60 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 61 | LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED 62 | LOCAL_CFLAGS += -DINCALL_STEREO_CAPTURE_ENABLED 63 | MULTIPLE_HW_VARIANTS_ENABLED := true 64 | endif 65 | ifneq ($(filter msmnile,$(TARGET_BOARD_PLATFORM)),) 66 | LOCAL_CFLAGS := -DPLATFORM_SM8150 67 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4" 68 | LOCAL_CFLAGS += -DINCALL_MUSIC_ENABLED 69 | LOCAL_CFLAGS += -DINCALL_STEREO_CAPTURE_ENABLED 70 | MULTIPLE_HW_VARIANTS_ENABLED := true 71 | endif 72 | endif 73 | 74 | ifneq ($(filter msm8916 msm8909 msm8952,$(TARGET_BOARD_PLATFORM)),) 75 | AUDIO_PLATFORM = msm8916 76 | LOCAL_CFLAGS := -DPLATFORM_MSM8916 77 | ifneq ($(filter msm8909,$(TARGET_BOARD_PLATFORM)),) 78 | LOCAL_CFLAGS := -DPLATFORM_MSM8909 79 | endif 80 | LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="2" 81 | LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED 82 | MULTIPLE_HW_VARIANTS_ENABLED := true 83 | endif 84 | 85 | LOCAL_SRC_FILES := \ 86 | audio_hw.c \ 87 | voice.c \ 88 | platform_info.c \ 89 | audio_extn/ext_speaker.c \ 90 | audio_extn/audio_extn.c \ 91 | audio_extn/utils.c \ 92 | $(AUDIO_PLATFORM)/platform.c \ 93 | acdb.c 94 | 95 | ifdef MULTIPLE_HW_VARIANTS_ENABLED 96 | LOCAL_CFLAGS += -DHW_VARIANTS_ENABLED 97 | LOCAL_SRC_FILES += $(AUDIO_PLATFORM)/hw_info.c 98 | endif 99 | 100 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_TUNNEL)),true) 101 | LOCAL_CFLAGS += -DUSB_TUNNEL_ENABLED 102 | LOCAL_SRC_FILES += audio_extn/usb.c 103 | endif 104 | 105 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_SIDETONE_VOLUME)),true) 106 | LOCAL_CFLAGS += -DUSB_SIDETONE_VOLUME 107 | endif 108 | 109 | LOCAL_SHARED_LIBRARIES := \ 110 | libaudioutils \ 111 | liblog \ 112 | libcutils \ 113 | libprocessgroup \ 114 | libtinyalsa \ 115 | libtinycompress \ 116 | libaudioroute \ 117 | libdl \ 118 | libexpat 119 | 120 | LOCAL_C_INCLUDES += \ 121 | external/tinyalsa/include \ 122 | external/tinycompress/include \ 123 | $(call include-path-for, audio-route) \ 124 | $(call include-path-for, audio-effects) \ 125 | $(LOCAL_PATH)/$(AUDIO_PLATFORM) \ 126 | $(LOCAL_PATH)/audio_extn \ 127 | $(LOCAL_PATH)/voice_extn \ 128 | external/expat/lib 129 | 130 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SMART_PA_TFA_98XX)),true) 131 | LOCAL_SHARED_LIBRARIES += libexTfa98xx 132 | LOCAL_CFLAGS += -DSMART_PA_TFA_98XX_SUPPORTED 133 | LOCAL_SRC_FILES += audio_extn/tfa_98xx.c 134 | endif 135 | 136 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS)),true) 137 | LOCAL_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED 138 | LOCAL_SRC_FILES += voice_extn/voice_extn.c 139 | endif 140 | 141 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HFP)),true) 142 | LOCAL_CFLAGS += -DHFP_ENABLED 143 | LOCAL_SRC_FILES += audio_extn/hfp.c 144 | endif 145 | 146 | ifeq ($(strip $(AUDIO_FEATURE_SUPPORTED_EXTERNAL_BT)),true) 147 | LOCAL_CFLAGS += -DEXTERNAL_BT_SUPPORTED 148 | endif 149 | 150 | ifeq ($(strip $(AUDIO_FEATURE_FLICKER_SENSOR_INPUT)),true) 151 | LOCAL_CFLAGS += -DFLICKER_SENSOR_INPUT 152 | endif 153 | 154 | ifeq ($(strip $(AUDIO_FEATURE_NO_AUDIO_OUT)),true) 155 | LOCAL_CFLAGS += -DNO_AUDIO_OUT 156 | endif 157 | 158 | ifeq ($(strip $(BOARD_SUPPORTS_SOUND_TRIGGER)),true) 159 | LOCAL_CFLAGS += -DSOUND_TRIGGER_ENABLED 160 | LOCAL_CFLAGS += -DSOUND_TRIGGER_PLATFORM_NAME=$(TARGET_BOARD_PLATFORM) 161 | LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/sound_trigger 162 | LOCAL_SRC_FILES += audio_extn/soundtrigger.c 163 | ifneq ($(filter msm8996,$(TARGET_BOARD_PLATFORM)),) 164 | LOCAL_HEADER_LIBRARIES := sound_trigger.primary_headers 165 | endif 166 | 167 | endif 168 | 169 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SPKR_PROTECTION)),true) 170 | LOCAL_CFLAGS += -DSPKR_PROT_ENABLED 171 | LOCAL_SRC_FILES += audio_extn/spkr_protection.c 172 | endif 173 | 174 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CIRRUS_SPKR_PROTECTION)),true) 175 | LOCAL_CFLAGS += -DSPKR_PROT_ENABLED 176 | LOCAL_SRC_FILES += audio_extn/cirrus_playback.c 177 | endif 178 | 179 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DSM_FEEDBACK)),true) 180 | LOCAL_CFLAGS += -DDSM_FEEDBACK_ENABLED 181 | LOCAL_SRC_FILES += audio_extn/dsm_feedback.c 182 | endif 183 | 184 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_A2DP_OFFLOAD)),true) 185 | LOCAL_CFLAGS += -DA2DP_OFFLOAD_ENABLED 186 | LOCAL_SRC_FILES += audio_extn/a2dp.c 187 | endif 188 | 189 | ifneq ($(filter msm8992 msm8994 msm8996 msm8998 sdm845 sdm710,$(TARGET_BOARD_PLATFORM)),) 190 | # push codec/mad calibration to HW dep node 191 | # applicable to msm8992/8994 or newer platforms 192 | LOCAL_CFLAGS += -DHWDEP_CAL_ENABLED 193 | LOCAL_SRC_FILES += audio_extn/hwdep_cal.c 194 | endif 195 | 196 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SND_MONITOR)), true) 197 | LOCAL_CFLAGS += -DSND_MONITOR_ENABLED 198 | LOCAL_SRC_FILES += audio_extn/sndmonitor.c 199 | endif 200 | 201 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_SERVICE_INTERVAL)), true) 202 | LOCAL_CFLAGS += -DUSB_SERVICE_INTERVAL_ENABLED 203 | endif 204 | 205 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_MAXX_AUDIO)), true) 206 | LOCAL_CFLAGS += -DMAXXAUDIO_QDSP_ENABLED 207 | LOCAL_SRC_FILES += audio_extn/maxxaudio.c 208 | endif 209 | 210 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUDIO_ZOOM)), true) 211 | LOCAL_CFLAGS += -DAUDIOZOOM_QDSP_ENABLED 212 | LOCAL_SRC_FILES += audio_extn/audiozoom.c 213 | endif 214 | 215 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_24BITS_CAMCORDER)), true) 216 | LOCAL_CFLAGS += -DENABLED_24BITS_CAMCORDER 217 | endif 218 | 219 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_BG_CAL)),true) 220 | LOCAL_CFLAGS += -DBG_CODEC_CAL 221 | endif 222 | 223 | ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DYNAMIC_ECNS)),true) 224 | LOCAL_CFLAGS += -DDYNAMIC_ECNS_ENABLED 225 | endif 226 | 227 | LOCAL_SHARED_LIBRARIES += libbase libhidlbase libutils android.hardware.power@1.2 liblog 228 | 229 | LOCAL_SHARED_LIBRARIES += android.hardware.power-V1-ndk_platform 230 | LOCAL_SHARED_LIBRARIES += libbinder_ndk 231 | 232 | LOCAL_SRC_FILES += audio_perf.cpp 233 | 234 | LOCAL_HEADER_LIBRARIES += libhardware_headers 235 | 236 | LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM) 237 | LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 238 | LOCAL_LICENSE_CONDITIONS := notice 239 | 240 | LOCAL_MODULE_RELATIVE_PATH := hw 241 | 242 | LOCAL_MODULE_TAGS := optional 243 | 244 | LOCAL_MODULE_OWNER := qcom 245 | 246 | LOCAL_PROPRIETARY_MODULE := true 247 | 248 | LOCAL_CFLAGS += -Werror 249 | 250 | include $(BUILD_SHARED_LIBRARY) 251 | 252 | endif 253 | -------------------------------------------------------------------------------- /hal/audio_extn/audiozoom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "audio_hw_audiozoom" 18 | /*#define LOG_NDEBUG 0*/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "audio_extn.h" 28 | 29 | #include "audiozoom.h" 30 | 31 | #include 32 | 33 | #define AUDIOZOOM_PRESET_FILE "/vendor/etc/audiozoom.xml" 34 | 35 | typedef struct qdsp_audiozoom_cfg { 36 | uint32_t topo_id; 37 | uint32_t module_id; 38 | uint32_t instance_id; 39 | uint32_t zoom_param_id; 40 | uint32_t wide_param_id; 41 | uint32_t dir_param_id; 42 | uint32_t app_type; 43 | } qdsp_audiozoom_cfg_t; 44 | 45 | static qdsp_audiozoom_cfg_t qdsp_audiozoom; 46 | 47 | static void start_tag(void *userdata __unused, const XML_Char *tag_name, 48 | const XML_Char **attr) 49 | { 50 | uint32_t index = 0; 51 | 52 | if (!attr) { 53 | ALOGE("%s: NULL platform/tag_name/attr", __func__); 54 | return; 55 | } 56 | 57 | if (strcmp(tag_name, "topo") == 0) { 58 | if (strcmp(attr[0], "id") == 0) { 59 | if (attr[1]) 60 | qdsp_audiozoom.topo_id = atoi(attr[1]); 61 | } 62 | } else if (strcmp(tag_name, "module") == 0) { 63 | if (strcmp(attr[0], "id") == 0) { 64 | if (attr[1]) 65 | qdsp_audiozoom.module_id = atoi(attr[1]); 66 | } 67 | } else if (strcmp(tag_name, "param") == 0) { 68 | while (attr[index] != NULL) { 69 | if (strcmp(attr[index], "zoom_id") == 0) { 70 | index++; 71 | if (attr[index]) 72 | qdsp_audiozoom.zoom_param_id = atoi(attr[index]); 73 | else 74 | break; 75 | } else if (strcmp(attr[index], "wide_id") == 0) { 76 | index++; 77 | if (attr[index]) 78 | qdsp_audiozoom.wide_param_id = atoi(attr[index]); 79 | else 80 | break; 81 | } else if (strcmp(attr[index], "dir_id") == 0) { 82 | index++; 83 | if (attr[index]) 84 | qdsp_audiozoom.dir_param_id = atoi(attr[index]); 85 | else 86 | break; 87 | } 88 | index++; 89 | } 90 | } else if (strcmp(tag_name, "app_type") == 0) { 91 | if (strcmp(attr[0], "id") == 0) { 92 | if (attr[1]) 93 | qdsp_audiozoom.app_type = atoi(attr[1]); 94 | } 95 | } else if (strcmp(tag_name, "instance") == 0) { 96 | if (strcmp(attr[0], "id") == 0) { 97 | if (attr[1]) 98 | qdsp_audiozoom.instance_id = atoi(attr[1]); 99 | } 100 | } else { 101 | ALOGE("%s: %s is not a supported tag", __func__, tag_name); 102 | } 103 | 104 | return; 105 | } 106 | 107 | static void end_tag(void *userdata __unused, const XML_Char *tag_name) 108 | { 109 | if (strcmp(tag_name, "topo") == 0) { 110 | } else if (strcmp(tag_name, "module") == 0) { 111 | } else if (strcmp(tag_name, "param") == 0) { 112 | } else if (strcmp(tag_name, "app_type") == 0) { 113 | } else if (strcmp(tag_name, "instance") == 0) { 114 | } else { 115 | ALOGE("%s: %s is not a supported tag", __func__, tag_name); 116 | } 117 | } 118 | 119 | static int audio_extn_audiozoom_parse_info(const char *filename) 120 | { 121 | XML_Parser parser; 122 | FILE *file; 123 | int ret = 0; 124 | int bytes_read; 125 | void *buf; 126 | static const uint32_t kBufSize = 1024; 127 | 128 | file = fopen(filename, "r"); 129 | if (!file) { 130 | ALOGE("%s: Failed to open %s", __func__, filename); 131 | ret = -ENODEV; 132 | goto done; 133 | } 134 | 135 | parser = XML_ParserCreate(NULL); 136 | if (!parser) { 137 | ALOGE("%s: Failed to create XML parser!", __func__); 138 | ret = -ENODEV; 139 | goto err_close_file; 140 | } 141 | 142 | XML_SetElementHandler(parser, start_tag, end_tag); 143 | 144 | while (1) { 145 | buf = XML_GetBuffer(parser, kBufSize); 146 | if (buf == NULL) { 147 | ALOGE("%s: XML_GetBuffer failed", __func__); 148 | ret = -ENOMEM; 149 | goto err_free_parser; 150 | } 151 | 152 | bytes_read = fread(buf, 1, kBufSize, file); 153 | if (bytes_read < 0) { 154 | ALOGE("%s: fread failed, bytes read = %d", __func__, bytes_read); 155 | ret = bytes_read; 156 | goto err_free_parser; 157 | } 158 | 159 | if (XML_ParseBuffer(parser, bytes_read, 160 | bytes_read == 0) == XML_STATUS_ERROR) { 161 | ALOGE("%s: XML_ParseBuffer failed, for %s", 162 | __func__, filename); 163 | ret = -EINVAL; 164 | goto err_free_parser; 165 | } 166 | 167 | if (bytes_read == 0) 168 | break; 169 | } 170 | 171 | err_free_parser: 172 | XML_ParserFree(parser); 173 | err_close_file: 174 | fclose(file); 175 | done: 176 | return ret; 177 | } 178 | 179 | int audio_extn_audiozoom_set_microphone_direction( 180 | struct stream_in *in, audio_microphone_direction_t dir) 181 | { 182 | (void)in; 183 | (void)dir; 184 | return 0; 185 | } 186 | 187 | static int audio_extn_audiozoom_set_microphone_field_dimension_zoom( 188 | struct stream_in *in, float zoom) 189 | { 190 | struct audio_device *adev = in->dev; 191 | struct str_parms *parms = str_parms_create(); 192 | /* The encoding process in b64_ntop represents 24-bit groups of input bits 193 | as output strings of 4 encoded characters. */ 194 | char data[((sizeof(zoom) + 2) / 3) * 4 + 1] = {0}; 195 | int32_t ret; 196 | 197 | if (zoom > 1.0 || zoom < 0) 198 | return -EINVAL; 199 | 200 | if (qdsp_audiozoom.topo_id == 0 || qdsp_audiozoom.module_id == 0 || 201 | qdsp_audiozoom.zoom_param_id == 0) 202 | return -ENOSYS; 203 | 204 | str_parms_add_int(parms, "cal_devid", in->device); 205 | str_parms_add_int(parms, "cal_apptype", in->app_type_cfg.app_type); 206 | str_parms_add_int(parms, "cal_topoid", qdsp_audiozoom.topo_id); 207 | str_parms_add_int(parms, "cal_moduleid", qdsp_audiozoom.module_id); 208 | str_parms_add_int(parms, "cal_instanceid", qdsp_audiozoom.instance_id); 209 | str_parms_add_int(parms, "cal_paramid", qdsp_audiozoom.zoom_param_id); 210 | 211 | ret = b64_ntop((uint8_t*)&zoom, sizeof(zoom), data, sizeof(data)); 212 | if (ret > 0) { 213 | str_parms_add_str(parms, "cal_data", data); 214 | 215 | platform_set_parameters(adev->platform, parms); 216 | } else { 217 | ALOGE("%s: failed to convert data to string, ret %d", __func__, ret); 218 | } 219 | 220 | str_parms_destroy(parms); 221 | 222 | return 0; 223 | } 224 | 225 | static int audio_extn_audiozoom_set_microphone_field_dimension_wide_angle( 226 | struct stream_in *in, float zoom) 227 | { 228 | (void)in; 229 | (void)zoom; 230 | return 0; 231 | } 232 | 233 | int audio_extn_audiozoom_set_microphone_field_dimension( 234 | struct stream_in *in, float zoom) 235 | { 236 | if (zoom > 1.0 || zoom < -1.0) 237 | return -EINVAL; 238 | 239 | if (zoom >= 0 && zoom <= 1.0) 240 | return audio_extn_audiozoom_set_microphone_field_dimension_zoom(in, zoom); 241 | 242 | if (zoom >= -1.0 && zoom <= 0) 243 | return audio_extn_audiozoom_set_microphone_field_dimension_wide_angle(in, zoom); 244 | 245 | return 0; 246 | } 247 | 248 | int audio_extn_audiozoom_init() 249 | { 250 | audio_extn_audiozoom_parse_info(AUDIOZOOM_PRESET_FILE); 251 | 252 | ALOGV("%s: topo_id=%d, module_id=%d, instance_id=%d, zoom__id=%d, dir_id=%d, app_type=%d", 253 | __func__, qdsp_audiozoom.topo_id, qdsp_audiozoom.module_id, qdsp_audiozoom.instance_id, 254 | qdsp_audiozoom.zoom_param_id, qdsp_audiozoom.dir_param_id,qdsp_audiozoom.app_type); 255 | 256 | return 0; 257 | } 258 | -------------------------------------------------------------------------------- /hal/audio_perf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "audio_hw_primary" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "audio_perf.h" 31 | 32 | // Protect gPowerHal_1_2_ and gPowerHal_Aidl_ 33 | static android::sp gPowerHal_1_2_; 34 | static std::shared_ptr gPowerHal_Aidl_; 35 | static std::mutex gPowerHalMutex; 36 | static constexpr int kDefaultBoostDurationMs = 2000; 37 | static constexpr int kBoostOff = -1; 38 | 39 | static const std::string kInstance = 40 | std::string(aidl::android::hardware::power::IPower::descriptor) + "/default"; 41 | 42 | enum hal_version { 43 | NONE, 44 | HIDL_1_2, 45 | AIDL, 46 | }; 47 | 48 | // Connnect PowerHAL 49 | static hal_version connectPowerHalLocked() { 50 | static bool gPowerHalHidlExists = true; 51 | static bool gPowerHalAidlExists = true; 52 | 53 | if (!gPowerHalHidlExists && !gPowerHalAidlExists) { 54 | return NONE; 55 | } 56 | 57 | if (gPowerHalHidlExists) { 58 | // (re)connect if handle is null 59 | if (!gPowerHal_1_2_) { 60 | gPowerHal_1_2_ = 61 | android::hardware::power::V1_2::IPower::getService(); 62 | } 63 | if (gPowerHal_1_2_) { 64 | ALOGV("Successfully connected to Power Hal Hidl service."); 65 | return HIDL_1_2; 66 | } else { 67 | // no more try on this handle 68 | gPowerHalHidlExists = false; 69 | } 70 | } 71 | 72 | if (gPowerHalAidlExists) { 73 | // (re)connect if handle is null 74 | if (!gPowerHal_Aidl_) { 75 | ndk::SpAIBinder pwBinder = ndk::SpAIBinder( 76 | AServiceManager_getService(kInstance.c_str())); 77 | gPowerHal_Aidl_ = aidl::android::hardware::power::IPower::fromBinder(pwBinder); 78 | } 79 | if (gPowerHal_Aidl_) { 80 | ALOGV("Successfully connected to Power Hal Aidl service."); 81 | return AIDL; 82 | } else { 83 | // no more try on this handle 84 | gPowerHalAidlExists = false; 85 | } 86 | } 87 | 88 | return NONE; 89 | } 90 | 91 | bool audio_streaming_hint_start() { 92 | std::lock_guard lock(gPowerHalMutex); 93 | switch(connectPowerHalLocked()) { 94 | case NONE: 95 | return false; 96 | case HIDL_1_2: 97 | { 98 | auto ret = gPowerHal_1_2_->powerHintAsync_1_2( 99 | android::hardware::power::V1_2::PowerHint::AUDIO_STREAMING, 100 | 1); 101 | if (!ret.isOk()) { 102 | ALOGE("powerHint failed, error: %s", 103 | ret.description().c_str()); 104 | gPowerHal_1_2_ = nullptr; 105 | return false; 106 | } 107 | return true; 108 | } 109 | case AIDL: 110 | { 111 | auto ret = gPowerHal_Aidl_->setBoost( 112 | aidl::android::hardware::power::Boost::AUDIO_LAUNCH, 113 | kDefaultBoostDurationMs); 114 | if (!ret.isOk()) { 115 | std::string err = ret.getDescription(); 116 | ALOGE("Failed to set power hint. Error: %s", err.c_str()); 117 | gPowerHal_Aidl_ = nullptr; 118 | return false; 119 | } 120 | return true; 121 | } 122 | default: 123 | ALOGE("Unknown HAL state"); 124 | return false; 125 | } 126 | } 127 | 128 | bool audio_streaming_hint_end() { 129 | std::lock_guard lock(gPowerHalMutex); 130 | switch(connectPowerHalLocked()) { 131 | case NONE: 132 | return false; 133 | case HIDL_1_2: 134 | { 135 | auto ret = gPowerHal_1_2_->powerHintAsync_1_2( 136 | android::hardware::power::V1_2::PowerHint::AUDIO_STREAMING, 137 | 0); 138 | if (!ret.isOk()) { 139 | ALOGE("powerHint failed, error: %s", 140 | ret.description().c_str()); 141 | gPowerHal_1_2_ = nullptr; 142 | return false; 143 | } 144 | return true; 145 | } 146 | case AIDL: 147 | { 148 | auto ret = gPowerHal_Aidl_->setBoost( 149 | aidl::android::hardware::power::Boost::AUDIO_LAUNCH, 150 | kBoostOff); 151 | if (!ret.isOk()) { 152 | std::string err = ret.getDescription(); 153 | ALOGE("Failed to set power hint. Error: %s", err.c_str()); 154 | gPowerHal_Aidl_ = nullptr; 155 | return false; 156 | } 157 | return true; 158 | } 159 | default: 160 | ALOGE("Unknown HAL state"); 161 | return false; 162 | } 163 | } 164 | 165 | bool audio_low_latency_hint_start() { 166 | std::lock_guard lock(gPowerHalMutex); 167 | switch(connectPowerHalLocked()) { 168 | case NONE: 169 | return false; 170 | case HIDL_1_2: 171 | { 172 | auto ret = gPowerHal_1_2_->powerHintAsync_1_2( 173 | android::hardware::power::V1_2::PowerHint::AUDIO_LOW_LATENCY, 174 | 1); 175 | if (!ret.isOk()) { 176 | ALOGE("powerHint failed, error: %s", 177 | ret.description().c_str()); 178 | gPowerHal_1_2_ = nullptr; 179 | return false; 180 | } 181 | return true; 182 | } 183 | case AIDL: 184 | { 185 | auto ret = gPowerHal_Aidl_->setMode( 186 | aidl::android::hardware::power::Mode::AUDIO_STREAMING_LOW_LATENCY, 187 | true); 188 | if (!ret.isOk()) { 189 | std::string err = ret.getDescription(); 190 | ALOGE("Failed to set power hint. Error: %s", err.c_str()); 191 | gPowerHal_Aidl_ = nullptr; 192 | return false; 193 | } 194 | return true; 195 | } 196 | default: 197 | ALOGE("Unknown HAL state"); 198 | return false; 199 | } 200 | } 201 | 202 | bool audio_low_latency_hint_end() { 203 | std::lock_guard lock(gPowerHalMutex); 204 | switch(connectPowerHalLocked()) { 205 | case NONE: 206 | return false; 207 | case HIDL_1_2: 208 | { 209 | auto ret = gPowerHal_1_2_->powerHintAsync_1_2( 210 | android::hardware::power::V1_2::PowerHint::AUDIO_LOW_LATENCY, 211 | 0); 212 | if (!ret.isOk()) { 213 | ALOGE("powerHint failed, error: %s", 214 | ret.description().c_str()); 215 | gPowerHal_1_2_ = nullptr; 216 | return false; 217 | } 218 | return true; 219 | } 220 | case AIDL: 221 | { 222 | auto ret = gPowerHal_Aidl_->setMode( 223 | aidl::android::hardware::power::Mode::AUDIO_STREAMING_LOW_LATENCY, 224 | false); 225 | if (!ret.isOk()) { 226 | std::string err = ret.getDescription(); 227 | ALOGE("Failed to set power hint. Error: %s", err.c_str()); 228 | gPowerHal_Aidl_ = nullptr; 229 | return false; 230 | } 231 | return true; 232 | } 233 | default: 234 | ALOGE("Unknown HAL state"); 235 | return false; 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /legacy/libalsa-intf/alsa_audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2010, The Android Open-Source Project 3 | ** Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #ifndef _AUDIO_H_ 19 | #define _AUDIO_H_ 20 | 21 | #include 22 | #define PCM_ERROR_MAX 128 23 | 24 | struct pcm { 25 | int fd; 26 | int timer_fd; 27 | unsigned rate; 28 | unsigned channels; 29 | unsigned flags; 30 | unsigned format; 31 | unsigned running:1; 32 | int underruns; 33 | unsigned buffer_size; 34 | unsigned period_size; 35 | unsigned period_cnt; 36 | char error[PCM_ERROR_MAX]; 37 | struct snd_pcm_hw_params *hw_p; 38 | struct snd_pcm_sw_params *sw_p; 39 | struct snd_pcm_sync_ptr *sync_ptr; 40 | struct snd_pcm_channel_info ch[2]; 41 | void *addr; 42 | int card_no; 43 | int device_no; 44 | int start; 45 | }; 46 | 47 | enum decoder_alias { 48 | FORMAT_MP3, 49 | FORMAT_AC3_PASS_THROUGH = 2, 50 | }; 51 | 52 | #define FORMAT(v) SNDRV_PCM_FORMAT_##v 53 | 54 | #define PCM_OUT 0x00000000 55 | #define PCM_IN 0x10000000 56 | 57 | #define PCM_STEREO 0x00000000 58 | #define PCM_MONO 0x01000000 59 | #define PCM_QUAD 0x02000000 60 | #define PCM_5POINT1 0x04000000 61 | 62 | #define PCM_44100HZ 0x00000000 63 | #define PCM_48000HZ 0x00100000 64 | #define PCM_8000HZ 0x00200000 65 | #define PCM_RATE_MASK 0x00F00000 66 | 67 | #define PCM_MMAP 0x00010000 68 | #define PCM_NMMAP 0x00000000 69 | 70 | #define DEBUG_ON 0x00000001 71 | #define DEBUG_OFF 0x00000000 72 | 73 | #define PCM_PERIOD_CNT_MIN 2 74 | #define PCM_PERIOD_CNT_SHIFT 16 75 | #define PCM_PERIOD_CNT_MASK (0xF << PCM_PERIOD_CNT_SHIFT) 76 | #define PCM_PERIOD_SZ_MIN 128 77 | #define PCM_PERIOD_SZ_SHIFT 12 78 | #define PCM_PERIOD_SZ_MASK (0xF << PCM_PERIOD_SZ_SHIFT) 79 | 80 | #define TIMEOUT_INFINITE -1 81 | 82 | /* Acquire/release a pcm channel. 83 | * Returns non-zero on error 84 | */ 85 | 86 | struct mixer_ctl { 87 | struct mixer *mixer; 88 | struct snd_ctl_elem_info *info; 89 | char **ename; 90 | }; 91 | 92 | #define __snd_alloca(ptr,type) do { *ptr = (type *) alloca(sizeof(type)); memset(*ptr, 0, sizeof(type)); } while (0) 93 | #define snd_ctl_elem_id_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_id) 94 | #define snd_ctl_card_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_card_info) 95 | #define snd_ctl_event_alloca(ptr) __snd_alloca(ptr, snd_ctl_event) 96 | #define snd_ctl_elem_list_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_list) 97 | #define snd_ctl_elem_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_info) 98 | #define snd_ctl_elem_value_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_value) 99 | 100 | 101 | enum snd_pcm_stream_t { 102 | /** Playback stream */ 103 | SND_PCM_STREAM_PLAYBACK = 0, 104 | /** Capture stream */ 105 | SND_PCM_STREAM_CAPTURE, 106 | SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE 107 | }; 108 | 109 | enum _snd_ctl_elem_iface { 110 | /** Card level */ 111 | SND_CTL_ELEM_IFACE_CARD = 0, 112 | /** Hardware dependent device */ 113 | SND_CTL_ELEM_IFACE_HWDEP, 114 | /** Mixer */ 115 | SND_CTL_ELEM_IFACE_MIXER, 116 | /** PCM */ 117 | SND_CTL_ELEM_IFACE_PCM, 118 | /** RawMidi */ 119 | SND_CTL_ELEM_IFACE_RAWMIDI, 120 | /** Timer */ 121 | SND_CTL_ELEM_IFACE_TIMER, 122 | /** Sequencer */ 123 | SND_CTL_ELEM_IFACE_SEQUENCER, 124 | SND_CTL_ELEM_IFACE_LAST = SND_CTL_ELEM_IFACE_SEQUENCER 125 | }; 126 | 127 | struct mixer { 128 | int fd; 129 | struct snd_ctl_elem_info *info; 130 | struct mixer_ctl *ctl; 131 | unsigned count; 132 | }; 133 | 134 | int get_format(const char* name); 135 | const char *get_format_name(int format); 136 | const char *get_format_desc(int format); 137 | struct pcm *pcm_open(unsigned flags, char *device); 138 | int pcm_close(struct pcm *pcm); 139 | int pcm_ready(struct pcm *pcm); 140 | int mmap_buffer(struct pcm *pcm); 141 | u_int8_t *dst_address(struct pcm *pcm); 142 | int sync_ptr(struct pcm *pcm); 143 | 144 | void param_init(struct snd_pcm_hw_params *p); 145 | void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit); 146 | void param_set_min(struct snd_pcm_hw_params *p, int n, unsigned val); 147 | void param_set_int(struct snd_pcm_hw_params *p, int n, unsigned val); 148 | void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned val); 149 | int param_set_hw_refine(struct pcm *pcm, struct snd_pcm_hw_params *params); 150 | int param_set_hw_params(struct pcm *pcm, struct snd_pcm_hw_params *params); 151 | int param_set_sw_params(struct pcm *pcm, struct snd_pcm_sw_params *sparams); 152 | void param_dump(struct snd_pcm_hw_params *p); 153 | int pcm_prepare(struct pcm *pcm); 154 | long pcm_avail(struct pcm *pcm); 155 | 156 | /* Returns a human readable reason for the last error. */ 157 | const char *pcm_error(struct pcm *pcm); 158 | 159 | /* Returns the buffer size (int bytes) that should be used for pcm_write. 160 | * This will be 1/2 of the actual fifo size. 161 | */ 162 | int pcm_buffer_size(struct snd_pcm_hw_params *params); 163 | int pcm_period_size(struct snd_pcm_hw_params *params); 164 | 165 | /* Write data to the fifo. 166 | * Will start playback on the first write or on a write that 167 | * occurs after a fifo underrun. 168 | */ 169 | int pcm_write(struct pcm *pcm, void *data, unsigned count); 170 | int pcm_read(struct pcm *pcm, void *data, unsigned count); 171 | 172 | struct mixer; 173 | struct mixer_ctl; 174 | 175 | struct mixer *mixer_open(const char *device); 176 | void mixer_close(struct mixer *mixer); 177 | void mixer_dump(struct mixer *mixer); 178 | 179 | struct mixer_ctl *mixer_get_control(struct mixer *mixer, 180 | const char *name, unsigned index); 181 | struct mixer_ctl *mixer_get_nth_control(struct mixer *mixer, unsigned n); 182 | 183 | int mixer_ctl_set(struct mixer_ctl *ctl, unsigned percent); 184 | int mixer_ctl_select(struct mixer_ctl *ctl, const char *value); 185 | void mixer_ctl_get(struct mixer_ctl *ctl, unsigned *value); 186 | int mixer_ctl_set_value(struct mixer_ctl *ctl, int count, char ** argv); 187 | 188 | 189 | #define MAX_NUM_CODECS 32 190 | 191 | /* compressed audio support */ 192 | #ifdef QCOM_COMPRESSED_AUDIO_ENABLED 193 | struct snd_compr_caps { 194 | __u32 num_codecs; 195 | __u32 min_fragment_size; 196 | __u32 max_fragment_size; 197 | __u32 min_fragments; 198 | __u32 max_fragments; 199 | __u32 codecs[MAX_NUM_CODECS]; 200 | __u32 reserved[11]; 201 | }; 202 | 203 | struct snd_enc_wma { 204 | __u32 super_block_align; /* WMA Type-specific data */ 205 | __u32 bits_per_sample; 206 | __u32 channelmask; 207 | __u32 encodeopt; 208 | }; 209 | 210 | struct snd_enc_vorbis { 211 | int quality; 212 | __u32 managed; 213 | __u32 max_bit_rate; 214 | __u32 min_bit_rate; 215 | __u32 downmix; 216 | }; 217 | 218 | struct snd_enc_real { 219 | __u32 quant_bits; 220 | __u32 start_region; 221 | __u32 num_regions; 222 | }; 223 | 224 | struct snd_enc_flac { 225 | __u32 num; 226 | __u32 gain; 227 | }; 228 | 229 | struct snd_enc_generic { 230 | __u32 bw; /* encoder bandwidth */ 231 | int reserved[15]; 232 | }; 233 | 234 | union snd_codec_options { 235 | struct snd_enc_wma wma; 236 | struct snd_enc_vorbis vorbis; 237 | struct snd_enc_real real; 238 | struct snd_enc_flac flac; 239 | struct snd_enc_generic generic; 240 | }; 241 | 242 | struct snd_codec { 243 | __u32 id; 244 | __u32 ch_in; 245 | __u32 ch_out; 246 | __u32 sample_rate; 247 | __u32 bit_rate; 248 | __u32 rate_control; 249 | __u32 profile; 250 | __u32 level; 251 | __u32 ch_mode; 252 | __u32 format; 253 | __u32 align; 254 | union snd_codec_options options; 255 | __u32 reserved[3]; 256 | }; 257 | 258 | struct snd_compressed_buffer { 259 | size_t fragment_size; 260 | int fragments; 261 | }; 262 | 263 | /* */ 264 | struct snd_compr_params { 265 | struct snd_compressed_buffer buffer; 266 | struct snd_codec codec; 267 | }; 268 | 269 | struct snd_compr_tstamp { 270 | size_t copied_bytes; 271 | size_t copied_total; 272 | size_t decoded; 273 | size_t rendered; 274 | __u32 sampling_rate; 275 | uint64_t timestamp; 276 | }; 277 | 278 | #define SNDRV_COMPRESS_GET_CAPS _IOWR('C', 0x00, struct snd_compr_caps *) 279 | #define SNDRV_COMPRESS_GET_CODEC_CAPS _IOWR('C', 0x01, struct snd_compr_codec_caps *) 280 | #define SNDRV_COMPRESS_SET_PARAMS _IOW('C', 0x02, struct snd_compr_params *) 281 | #define SNDRV_COMPRESS_GET_PARAMS _IOR('C', 0x03, struct snd_compr_params *) 282 | #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x10, struct snd_compr_tstamp *) 283 | #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x11, struct snd_compr_avail *) 284 | #define SNDRV_COMPRESS_PAUSE _IO('C', 0x20) 285 | #define SNDRV_COMPRESS_RESUME _IO('C', 0x21) 286 | #define SNDRV_COMPRESS_START _IO('C', 0x22) 287 | #define SNDRV_COMPRESS_STOP _IO('C', 0x23) 288 | #define SNDRV_COMPRESS_DRAIN _IO('C', 0x24) 289 | #endif 290 | 291 | #endif 292 | -------------------------------------------------------------------------------- /legacy/alsa_sound/AudioUtil.cpp: -------------------------------------------------------------------------------- 1 | /* AudioUtil.cpp 2 | * 3 | * Copyright (C) 2012 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #define LOG_TAG "AudioUtil" 19 | //#define LOG_NDEBUG 0 20 | #include 21 | 22 | #include "AudioUtil.h" 23 | 24 | int AudioUtil::printFormatFromEDID(unsigned char format) { 25 | switch (format) { 26 | case LPCM: 27 | ALOGV("Format:LPCM"); 28 | break; 29 | case AC3: 30 | ALOGV("Format:AC-3"); 31 | break; 32 | case MPEG1: 33 | ALOGV("Format:MPEG1 (Layers 1 & 2)"); 34 | break; 35 | case MP3: 36 | ALOGV("Format:MP3 (MPEG1 Layer 3)"); 37 | break; 38 | case MPEG2_MULTI_CHANNEL: 39 | ALOGV("Format:MPEG2 (multichannel)"); 40 | break; 41 | case AAC: 42 | ALOGV("Format:AAC"); 43 | break; 44 | case DTS: 45 | ALOGV("Format:DTS"); 46 | break; 47 | case ATRAC: 48 | ALOGV("Format:ATRAC"); 49 | break; 50 | case SACD: 51 | ALOGV("Format:One-bit audio aka SACD"); 52 | break; 53 | case DOLBY_DIGITAL_PLUS: 54 | ALOGV("Format:Dolby Digital +"); 55 | break; 56 | case DTS_HD: 57 | ALOGV("Format:DTS-HD"); 58 | break; 59 | case MAT: 60 | ALOGV("Format:MAT (MLP)"); 61 | break; 62 | case DST: 63 | ALOGV("Format:DST"); 64 | break; 65 | case WMA_PRO: 66 | ALOGV("Format:WMA Pro"); 67 | break; 68 | default: 69 | ALOGV("Invalid format ID...."); 70 | break; 71 | } 72 | return format; 73 | } 74 | 75 | int AudioUtil::getSamplingFrequencyFromEDID(unsigned char byte) { 76 | int nFreq = 0; 77 | 78 | if (byte & BIT(6)) { 79 | ALOGV("192kHz"); 80 | nFreq = 192000; 81 | } else if (byte & BIT(5)) { 82 | ALOGV("176kHz"); 83 | nFreq = 176000; 84 | } else if (byte & BIT(4)) { 85 | ALOGV("96kHz"); 86 | nFreq = 96000; 87 | } else if (byte & BIT(3)) { 88 | ALOGV("88.2kHz"); 89 | nFreq = 88200; 90 | } else if (byte & BIT(2)) { 91 | ALOGV("48kHz"); 92 | nFreq = 48000; 93 | } else if (byte & BIT(1)) { 94 | ALOGV("44.1kHz"); 95 | nFreq = 44100; 96 | } else if (byte & BIT(0)) { 97 | ALOGV("32kHz"); 98 | nFreq = 32000; 99 | } 100 | return nFreq; 101 | } 102 | 103 | int AudioUtil::getBitsPerSampleFromEDID(unsigned char byte, 104 | unsigned char format) { 105 | int nBitsPerSample = 0; 106 | if (format == 1) { 107 | if (byte & BIT(2)) { 108 | ALOGV("24bit"); 109 | nBitsPerSample = 24; 110 | } else if (byte & BIT(1)) { 111 | ALOGV("20bit"); 112 | nBitsPerSample = 20; 113 | } else if (byte & BIT(0)) { 114 | ALOGV("16bit"); 115 | nBitsPerSample = 16; 116 | } 117 | } else { 118 | ALOGV("not lpcm format, return 0"); 119 | return 0; 120 | } 121 | return nBitsPerSample; 122 | } 123 | 124 | bool AudioUtil::getHDMIAudioSinkCaps(EDID_AUDIO_INFO* pInfo) { 125 | unsigned char channels[16]; 126 | unsigned char formats[16]; 127 | unsigned char frequency[16]; 128 | unsigned char bitrate[16]; 129 | unsigned char* data = NULL; 130 | unsigned char* original_data_ptr = NULL; 131 | int count = 0; 132 | bool bRet = false; 133 | const char* file = "/sys/class/graphics/fb1/audio_data_block"; 134 | FILE* fpaudiocaps = fopen(file, "rb"); 135 | if (fpaudiocaps) { 136 | ALOGV("opened audio_caps successfully..."); 137 | fseek(fpaudiocaps, 0, SEEK_END); 138 | long size = ftell(fpaudiocaps); 139 | ALOGV("audiocaps size is %ld\n",size); 140 | data = (unsigned char*) malloc(size); 141 | if (data) { 142 | fseek(fpaudiocaps, 0, SEEK_SET); 143 | original_data_ptr = data; 144 | fread(data, 1, size, fpaudiocaps); 145 | } 146 | fclose(fpaudiocaps); 147 | } else { 148 | ALOGE("failed to open audio_caps"); 149 | } 150 | 151 | if (pInfo && data) { 152 | int length = 0; 153 | memcpy(&count, data, sizeof(int)); 154 | data+= sizeof(int); 155 | ALOGV("#Audio Block Count is %d",count); 156 | memcpy(&length, data, sizeof(int)); 157 | data += sizeof(int); 158 | ALOGV("Total length is %d",length); 159 | unsigned int sad[MAX_SHORT_AUDIO_DESC_CNT]; 160 | int nblockindex = 0; 161 | int nCountDesc = 0; 162 | while (length >= MIN_AUDIO_DESC_LENGTH && count < MAX_SHORT_AUDIO_DESC_CNT) { 163 | sad[nblockindex] = (unsigned int)data[0] + ((unsigned int)data[1] << 8) 164 | + ((unsigned int)data[2] << 16); 165 | nblockindex+=1; 166 | nCountDesc++; 167 | length -= MIN_AUDIO_DESC_LENGTH; 168 | data += MIN_AUDIO_DESC_LENGTH; 169 | } 170 | memset(pInfo, 0, sizeof(EDID_AUDIO_INFO)); 171 | pInfo->nAudioBlocks = nCountDesc; 172 | ALOGV("Total # of audio descriptors %d",nCountDesc); 173 | int nIndex = 0; 174 | while (nCountDesc--) { 175 | channels [nIndex] = (sad[nIndex] & 0x7) + 1; 176 | formats [nIndex] = (sad[nIndex] & 0xFF) >> 3; 177 | frequency[nIndex] = (sad[nIndex] >> 8) & 0xFF; 178 | bitrate [nIndex] = (sad[nIndex] >> 16) & 0xFF; 179 | nIndex++; 180 | } 181 | bRet = true; 182 | for (int i = 0; i < pInfo->nAudioBlocks; i++) { 183 | ALOGV("AUDIO DESC BLOCK # %d\n",i); 184 | 185 | pInfo->AudioBlocksArray[i].nChannels = channels[i]; 186 | ALOGV("pInfo->AudioBlocksArray[i].nChannels %d\n", pInfo->AudioBlocksArray[i].nChannels); 187 | 188 | ALOGV("Format Byte %d\n", formats[i]); 189 | pInfo->AudioBlocksArray[i].nFormatId = (EDID_AUDIO_FORMAT_ID)printFormatFromEDID(formats[i]); 190 | ALOGV("pInfo->AudioBlocksArray[i].nFormatId %d",pInfo->AudioBlocksArray[i].nFormatId); 191 | 192 | ALOGV("Frequency Byte %d\n", frequency[i]); 193 | pInfo->AudioBlocksArray[i].nSamplingFreq = getSamplingFrequencyFromEDID(frequency[i]); 194 | ALOGV("pInfo->AudioBlocksArray[i].nSamplingFreq %d",pInfo->AudioBlocksArray[i].nSamplingFreq); 195 | 196 | ALOGV("BitsPerSample Byte %d\n", bitrate[i]); 197 | pInfo->AudioBlocksArray[i].nBitsPerSample = getBitsPerSampleFromEDID(bitrate[i],formats[i]); 198 | ALOGV("pInfo->AudioBlocksArray[i].nBitsPerSample %d",pInfo->AudioBlocksArray[i].nBitsPerSample); 199 | } 200 | getSpeakerAllocation(pInfo); 201 | } 202 | if (original_data_ptr) 203 | free(original_data_ptr); 204 | 205 | return bRet; 206 | } 207 | 208 | bool AudioUtil::getSpeakerAllocation(EDID_AUDIO_INFO* pInfo) { 209 | int count = 0; 210 | bool bRet = false; 211 | unsigned char* data = NULL; 212 | unsigned char* original_data_ptr = NULL; 213 | const char* spkrfile = "/sys/class/graphics/fb1/spkr_alloc_data_block"; 214 | FILE* fpspkrfile = fopen(spkrfile, "rb"); 215 | if(fpspkrfile) { 216 | ALOGV("opened spkr_alloc_data_block successfully..."); 217 | fseek(fpspkrfile,0,SEEK_END); 218 | long size = ftell(fpspkrfile); 219 | ALOGV("fpspkrfile size is %ld\n",size); 220 | data = (unsigned char*)malloc(size); 221 | if(data) { 222 | original_data_ptr = data; 223 | fseek(fpspkrfile,0,SEEK_SET); 224 | fread(data,1,size,fpspkrfile); 225 | } 226 | fclose(fpspkrfile); 227 | } else { 228 | ALOGE("failed to open fpspkrfile"); 229 | } 230 | 231 | if(pInfo && data) { 232 | int length = 0; 233 | memcpy(&count, data, sizeof(int)); 234 | ALOGV("Count is %d",count); 235 | data += sizeof(int); 236 | memcpy(&length, data, sizeof(int)); 237 | ALOGV("Total length is %d",length); 238 | data+= sizeof(int); 239 | ALOGV("Total speaker allocation Block count # %d\n",count); 240 | bRet = true; 241 | for (int i = 0; i < count; i++) { 242 | ALOGV("Speaker Allocation BLOCK # %d\n",i); 243 | pInfo->nSpeakerAllocation[0] = data[0]; 244 | pInfo->nSpeakerAllocation[1] = data[1]; 245 | pInfo->nSpeakerAllocation[2] = data[2]; 246 | ALOGV("pInfo->nSpeakerAllocation %x %x %x\n", data[0],data[1],data[2]); 247 | 248 | 249 | if (pInfo->nSpeakerAllocation[0] & BIT(7)) { 250 | ALOGV("FLW/FRW"); 251 | } else if (pInfo->nSpeakerAllocation[0] & BIT(6)) { 252 | ALOGV("RLC/RRC"); 253 | } else if (pInfo->nSpeakerAllocation[0] & BIT(5)) { 254 | ALOGV("FLC/FRC"); 255 | } else if (pInfo->nSpeakerAllocation[0] & BIT(4)) { 256 | ALOGV("RC"); 257 | } else if (pInfo->nSpeakerAllocation[0] & BIT(3)) { 258 | ALOGV("RL/RR"); 259 | } else if (pInfo->nSpeakerAllocation[0] & BIT(2)) { 260 | ALOGV("FC"); 261 | } else if (pInfo->nSpeakerAllocation[0] & BIT(1)) { 262 | ALOGV("LFE"); 263 | } else if (pInfo->nSpeakerAllocation[0] & BIT(0)) { 264 | ALOGV("FL/FR"); 265 | } 266 | 267 | if (pInfo->nSpeakerAllocation[1] & BIT(2)) { 268 | ALOGV("FCH"); 269 | } else if (pInfo->nSpeakerAllocation[1] & BIT(1)) { 270 | ALOGV("TC"); 271 | } else if (pInfo->nSpeakerAllocation[1] & BIT(0)) { 272 | ALOGV("FLH/FRH"); 273 | } 274 | } 275 | } 276 | if (original_data_ptr) 277 | free(original_data_ptr); 278 | return bRet; 279 | } 280 | -------------------------------------------------------------------------------- /post_proc/bass_boost.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "offload_effect_bass_boost" 18 | //#define LOG_NDEBUG 0 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "effect_api.h" 27 | #include "bass_boost.h" 28 | 29 | /* Offload bassboost UUID: 2c4a8c24-1581-487f-94f6-0002a5d5c51b */ 30 | const effect_descriptor_t bassboost_descriptor = { 31 | {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 32 | {0x2c4a8c24, 0x1581, 0x487f, 0x94f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 33 | EFFECT_CONTROL_API_VERSION, 34 | (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_HW_ACC_TUNNEL | 35 | EFFECT_FLAG_VOLUME_CTRL), 36 | 0, /* TODO */ 37 | 1, 38 | "MSM offload bassboost", 39 | "The Android Open Source Project", 40 | }; 41 | 42 | /* 43 | * Bassboost operations 44 | */ 45 | 46 | int bassboost_get_strength(bassboost_context_t *context) 47 | { 48 | ALOGV("%s: strength: %d", __func__, context->strength); 49 | return context->strength; 50 | } 51 | 52 | int bassboost_set_strength(bassboost_context_t *context, uint32_t strength) 53 | { 54 | ALOGV("%s: strength: %d", __func__, strength); 55 | context->strength = strength; 56 | 57 | offload_bassboost_set_strength(&(context->offload_bass), strength); 58 | if (context->ctl) 59 | offload_bassboost_send_params(context->ctl, &context->offload_bass, 60 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | 61 | OFFLOAD_SEND_BASSBOOST_STRENGTH); 62 | return 0; 63 | } 64 | 65 | int bassboost_get_parameter(effect_context_t *context, effect_param_t *p, 66 | uint32_t *size) 67 | { 68 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 69 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 70 | int32_t *param_tmp = (int32_t *)p->data; 71 | int32_t param = *param_tmp++; 72 | void *value = p->data + voffset; 73 | int i; 74 | 75 | ALOGV("%s", __func__); 76 | 77 | p->status = 0; 78 | 79 | switch (param) { 80 | case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 81 | if (p->vsize < sizeof(uint32_t)) 82 | p->status = -EINVAL; 83 | p->vsize = sizeof(uint32_t); 84 | break; 85 | case BASSBOOST_PARAM_STRENGTH: 86 | if (p->vsize < sizeof(int16_t)) 87 | p->status = -EINVAL; 88 | p->vsize = sizeof(int16_t); 89 | break; 90 | default: 91 | p->status = -EINVAL; 92 | } 93 | 94 | *size = sizeof(effect_param_t) + voffset + p->vsize; 95 | 96 | if (p->status != 0) 97 | return 0; 98 | 99 | switch (param) { 100 | case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 101 | ALOGV("%s: BASSBOOST_PARAM_STRENGTH_SUPPORTED", __func__); 102 | *(uint32_t *)value = 1; 103 | break; 104 | 105 | case BASSBOOST_PARAM_STRENGTH: 106 | ALOGV("%s: BASSBOOST_PARAM_STRENGTH", __func__); 107 | *(int16_t *)value = bassboost_get_strength(bass_ctxt); 108 | break; 109 | 110 | default: 111 | p->status = -EINVAL; 112 | break; 113 | } 114 | 115 | return 0; 116 | } 117 | 118 | int bassboost_set_parameter(effect_context_t *context, effect_param_t *p, 119 | uint32_t size __unused) 120 | { 121 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 122 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 123 | void *value = p->data + voffset; 124 | int32_t *param_tmp = (int32_t *)p->data; 125 | int32_t param = *param_tmp++; 126 | uint32_t strength; 127 | 128 | ALOGV("%s", __func__); 129 | 130 | p->status = 0; 131 | 132 | switch (param) { 133 | case BASSBOOST_PARAM_STRENGTH: 134 | ALOGV("%s BASSBOOST_PARAM_STRENGTH", __func__); 135 | strength = (uint32_t)(*(int16_t *)value); 136 | bassboost_set_strength(bass_ctxt, strength); 137 | break; 138 | default: 139 | p->status = -EINVAL; 140 | break; 141 | } 142 | 143 | return 0; 144 | } 145 | 146 | int bassboost_set_device(effect_context_t *context, uint32_t device) 147 | { 148 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 149 | 150 | ALOGV("%s: device: %d", __func__, device); 151 | bass_ctxt->device = device; 152 | if ((device == AUDIO_DEVICE_OUT_SPEAKER) || 153 | (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) || 154 | (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) || 155 | (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) || 156 | (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) { 157 | if (!bass_ctxt->temp_disabled) { 158 | if (effect_is_active(&bass_ctxt->common)) { 159 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false); 160 | if (bass_ctxt->ctl) 161 | offload_bassboost_send_params(bass_ctxt->ctl, 162 | &bass_ctxt->offload_bass, 163 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); 164 | } 165 | bass_ctxt->temp_disabled = true; 166 | } 167 | } else { 168 | if (bass_ctxt->temp_disabled) { 169 | if (effect_is_active(&bass_ctxt->common)) { 170 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true); 171 | if (bass_ctxt->ctl) 172 | offload_bassboost_send_params(bass_ctxt->ctl, 173 | &bass_ctxt->offload_bass, 174 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); 175 | } 176 | bass_ctxt->temp_disabled = false; 177 | } 178 | } 179 | offload_bassboost_set_device(&(bass_ctxt->offload_bass), device); 180 | return 0; 181 | } 182 | 183 | int bassboost_reset(effect_context_t *context) 184 | { 185 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 186 | 187 | return 0; 188 | } 189 | 190 | int bassboost_init(effect_context_t *context) 191 | { 192 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 193 | 194 | ALOGV("%s", __func__); 195 | context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 196 | context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 197 | context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 198 | context->config.inputCfg.samplingRate = 44100; 199 | context->config.inputCfg.bufferProvider.getBuffer = NULL; 200 | context->config.inputCfg.bufferProvider.releaseBuffer = NULL; 201 | context->config.inputCfg.bufferProvider.cookie = NULL; 202 | context->config.inputCfg.mask = EFFECT_CONFIG_ALL; 203 | context->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 204 | context->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 205 | context->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 206 | context->config.outputCfg.samplingRate = 44100; 207 | context->config.outputCfg.bufferProvider.getBuffer = NULL; 208 | context->config.outputCfg.bufferProvider.releaseBuffer = NULL; 209 | context->config.outputCfg.bufferProvider.cookie = NULL; 210 | context->config.outputCfg.mask = EFFECT_CONFIG_ALL; 211 | 212 | set_config(context, &context->config); 213 | 214 | bass_ctxt->temp_disabled = false; 215 | memset(&(bass_ctxt->offload_bass), 0, sizeof(struct bass_boost_params)); 216 | 217 | return 0; 218 | } 219 | 220 | int bassboost_enable(effect_context_t *context) 221 | { 222 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 223 | 224 | ALOGV("%s", __func__); 225 | 226 | if (!offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)) && 227 | !(bass_ctxt->temp_disabled)) { 228 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true); 229 | if (bass_ctxt->ctl && bass_ctxt->strength) 230 | offload_bassboost_send_params(bass_ctxt->ctl, 231 | &bass_ctxt->offload_bass, 232 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | 233 | OFFLOAD_SEND_BASSBOOST_STRENGTH); 234 | } 235 | return 0; 236 | } 237 | 238 | int bassboost_disable(effect_context_t *context) 239 | { 240 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 241 | 242 | ALOGV("%s", __func__); 243 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) { 244 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false); 245 | if (bass_ctxt->ctl) 246 | offload_bassboost_send_params(bass_ctxt->ctl, 247 | &bass_ctxt->offload_bass, 248 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); 249 | } 250 | return 0; 251 | } 252 | 253 | int bassboost_start(effect_context_t *context, output_context_t *output) 254 | { 255 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 256 | 257 | ALOGV("%s", __func__); 258 | bass_ctxt->ctl = output->ctl; 259 | ALOGV("output->ctl: %p", output->ctl); 260 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) 261 | if (bass_ctxt->ctl) 262 | offload_bassboost_send_params(bass_ctxt->ctl, &bass_ctxt->offload_bass, 263 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | 264 | OFFLOAD_SEND_BASSBOOST_STRENGTH); 265 | return 0; 266 | } 267 | 268 | int bassboost_stop(effect_context_t *context, output_context_t *output __unused) 269 | { 270 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; 271 | 272 | ALOGV("%s", __func__); 273 | bass_ctxt->ctl = NULL; 274 | return 0; 275 | } 276 | -------------------------------------------------------------------------------- /post_proc/virtualizer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "offload_effect_virtualizer" 18 | //#define LOG_NDEBUG 0 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "effect_api.h" 27 | #include "virtualizer.h" 28 | 29 | /* Offload Virtualizer UUID: 509a4498-561a-4bea-b3b1-0002a5d5c51b */ 30 | const effect_descriptor_t virtualizer_descriptor = { 31 | {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 32 | {0x509a4498, 0x561a, 0x4bea, 0xb3b1, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 33 | EFFECT_CONTROL_API_VERSION, 34 | (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_HW_ACC_TUNNEL | 35 | EFFECT_FLAG_VOLUME_CTRL), 36 | 0, /* TODO */ 37 | 1, 38 | "MSM offload virtualizer", 39 | "The Android Open Source Project", 40 | }; 41 | 42 | /* 43 | * Virtualizer operations 44 | */ 45 | 46 | int virtualizer_get_strength(virtualizer_context_t *context) 47 | { 48 | ALOGV("%s: strength: %d", __func__, context->strength); 49 | return context->strength; 50 | } 51 | 52 | int virtualizer_set_strength(virtualizer_context_t *context, uint32_t strength) 53 | { 54 | ALOGV("%s: strength: %d", __func__, strength); 55 | context->strength = strength; 56 | 57 | offload_virtualizer_set_strength(&(context->offload_virt), strength); 58 | if (context->ctl) 59 | offload_virtualizer_send_params(context->ctl, &context->offload_virt, 60 | OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG | 61 | OFFLOAD_SEND_VIRTUALIZER_STRENGTH); 62 | return 0; 63 | } 64 | 65 | int virtualizer_get_parameter(effect_context_t *context, effect_param_t *p, 66 | uint32_t *size) 67 | { 68 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 69 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 70 | int32_t *param_tmp = (int32_t *)p->data; 71 | int32_t param = *param_tmp++; 72 | void *value = p->data + voffset; 73 | int i; 74 | 75 | ALOGV("%s", __func__); 76 | 77 | p->status = 0; 78 | 79 | switch (param) { 80 | case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 81 | if (p->vsize < sizeof(uint32_t)) 82 | p->status = -EINVAL; 83 | p->vsize = sizeof(uint32_t); 84 | break; 85 | case VIRTUALIZER_PARAM_STRENGTH: 86 | if (p->vsize < sizeof(int16_t)) 87 | p->status = -EINVAL; 88 | p->vsize = sizeof(int16_t); 89 | break; 90 | default: 91 | p->status = -EINVAL; 92 | } 93 | 94 | *size = sizeof(effect_param_t) + voffset + p->vsize; 95 | 96 | if (p->status != 0) 97 | return 0; 98 | 99 | switch (param) { 100 | case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 101 | ALOGV("%s: VIRTUALIZER_PARAM_STRENGTH_SUPPORTED", __func__); 102 | *(uint32_t *)value = 1; 103 | break; 104 | 105 | case VIRTUALIZER_PARAM_STRENGTH: 106 | ALOGV("%s: VIRTUALIZER_PARAM_STRENGTH", __func__); 107 | *(int16_t *)value = virtualizer_get_strength(virt_ctxt); 108 | break; 109 | 110 | default: 111 | p->status = -EINVAL; 112 | break; 113 | } 114 | 115 | return 0; 116 | } 117 | 118 | int virtualizer_set_parameter(effect_context_t *context, effect_param_t *p, 119 | uint32_t size __unused) 120 | { 121 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 122 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 123 | void *value = p->data + voffset; 124 | int32_t *param_tmp = (int32_t *)p->data; 125 | int32_t param = *param_tmp++; 126 | uint32_t strength; 127 | 128 | ALOGV("%s", __func__); 129 | 130 | p->status = 0; 131 | 132 | switch (param) { 133 | case VIRTUALIZER_PARAM_STRENGTH: 134 | ALOGV("%s VIRTUALIZER_PARAM_STRENGTH", __func__); 135 | strength = (uint32_t)(*(int16_t *)value); 136 | virtualizer_set_strength(virt_ctxt, strength); 137 | break; 138 | default: 139 | p->status = -EINVAL; 140 | break; 141 | } 142 | 143 | return 0; 144 | } 145 | 146 | int virtualizer_set_device(effect_context_t *context, uint32_t device) 147 | { 148 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 149 | 150 | ALOGV("%s: device: %d", __func__, device); 151 | virt_ctxt->device = device; 152 | if ((device == AUDIO_DEVICE_OUT_SPEAKER) || 153 | (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) || 154 | (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) || 155 | (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) || 156 | (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) { 157 | if (!virt_ctxt->temp_disabled) { 158 | if (effect_is_active(&virt_ctxt->common)) { 159 | offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), false); 160 | if (virt_ctxt->ctl) 161 | offload_virtualizer_send_params(virt_ctxt->ctl, 162 | &virt_ctxt->offload_virt, 163 | OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG); 164 | } 165 | virt_ctxt->temp_disabled = true; 166 | } 167 | } else { 168 | if (virt_ctxt->temp_disabled) { 169 | if (effect_is_active(&virt_ctxt->common)) { 170 | offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), true); 171 | if (virt_ctxt->ctl) 172 | offload_virtualizer_send_params(virt_ctxt->ctl, 173 | &virt_ctxt->offload_virt, 174 | OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG); 175 | } 176 | virt_ctxt->temp_disabled = false; 177 | } 178 | } 179 | offload_virtualizer_set_device(&(virt_ctxt->offload_virt), device); 180 | return 0; 181 | } 182 | 183 | int virtualizer_reset(effect_context_t *context) 184 | { 185 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 186 | 187 | return 0; 188 | } 189 | 190 | int virtualizer_init(effect_context_t *context) 191 | { 192 | ALOGV("%s", __func__); 193 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 194 | 195 | context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 196 | context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 197 | context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 198 | context->config.inputCfg.samplingRate = 44100; 199 | context->config.inputCfg.bufferProvider.getBuffer = NULL; 200 | context->config.inputCfg.bufferProvider.releaseBuffer = NULL; 201 | context->config.inputCfg.bufferProvider.cookie = NULL; 202 | context->config.inputCfg.mask = EFFECT_CONFIG_ALL; 203 | context->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 204 | context->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 205 | context->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 206 | context->config.outputCfg.samplingRate = 44100; 207 | context->config.outputCfg.bufferProvider.getBuffer = NULL; 208 | context->config.outputCfg.bufferProvider.releaseBuffer = NULL; 209 | context->config.outputCfg.bufferProvider.cookie = NULL; 210 | context->config.outputCfg.mask = EFFECT_CONFIG_ALL; 211 | 212 | set_config(context, &context->config); 213 | 214 | virt_ctxt->temp_disabled = false; 215 | memset(&(virt_ctxt->offload_virt), 0, sizeof(struct virtualizer_params)); 216 | 217 | return 0; 218 | } 219 | 220 | int virtualizer_enable(effect_context_t *context) 221 | { 222 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 223 | 224 | ALOGV("%s", __func__); 225 | 226 | if (!offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt)) && 227 | !(virt_ctxt->temp_disabled)) { 228 | offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), true); 229 | if (virt_ctxt->ctl && virt_ctxt->strength) 230 | offload_virtualizer_send_params(virt_ctxt->ctl, 231 | &virt_ctxt->offload_virt, 232 | OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG | 233 | OFFLOAD_SEND_BASSBOOST_STRENGTH); 234 | } 235 | return 0; 236 | } 237 | 238 | int virtualizer_disable(effect_context_t *context) 239 | { 240 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 241 | 242 | ALOGV("%s", __func__); 243 | if (offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt))) { 244 | offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), false); 245 | if (virt_ctxt->ctl) 246 | offload_virtualizer_send_params(virt_ctxt->ctl, 247 | &virt_ctxt->offload_virt, 248 | OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG); 249 | } 250 | return 0; 251 | } 252 | 253 | int virtualizer_start(effect_context_t *context, output_context_t *output) 254 | { 255 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 256 | 257 | ALOGV("%s", __func__); 258 | virt_ctxt->ctl = output->ctl; 259 | if (offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt))) 260 | if (virt_ctxt->ctl) 261 | offload_virtualizer_send_params(virt_ctxt->ctl, &virt_ctxt->offload_virt, 262 | OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG | 263 | OFFLOAD_SEND_VIRTUALIZER_STRENGTH); 264 | return 0; 265 | } 266 | 267 | int virtualizer_stop(effect_context_t *context, output_context_t *output __unused) 268 | { 269 | virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)context; 270 | 271 | ALOGV("%s", __func__); 272 | virt_ctxt->ctl = NULL; 273 | return 0; 274 | } 275 | -------------------------------------------------------------------------------- /legacy/libalsa-intf/alsaucm_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of Code Aurora Forum, Inc. nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include "alsa_ucm.h" 40 | #include "msm8960_use_cases.h" 41 | 42 | /* Function prototypes */ 43 | static void print_help_menu(void); 44 | static void alsaucm_test_cmd_svr(void); 45 | static int process_cmd(char *cmdStr); 46 | 47 | /* Global data */ 48 | snd_use_case_mgr_t *uc_mgr; 49 | 50 | /* Defines */ 51 | enum ucm_cmd_id { 52 | UCM_OPEN = 0, 53 | UCM_SET, 54 | UCM_LISTCARDS, 55 | UCM_LIST, 56 | UCM_GET, 57 | UCM_GETI, 58 | UCM_RESET, 59 | UCM_RELOAD, 60 | UCM_HELP, 61 | UCM_QUIT, 62 | UCM_UNKNOWN 63 | }; 64 | 65 | struct cmd { 66 | enum ucm_cmd_id code; 67 | const char *cmd_str; 68 | }; 69 | 70 | static struct cmd cmds[] = { 71 | { UCM_OPEN, "open" }, 72 | { UCM_SET, "set" }, 73 | { UCM_LISTCARDS, "listcards" }, 74 | { UCM_LIST, "list" }, 75 | { UCM_GET, "get" }, 76 | { UCM_GETI, "geti" }, 77 | { UCM_RESET, "reset" }, 78 | { UCM_RELOAD, "reload" }, 79 | { UCM_HELP, "help" }, 80 | { UCM_QUIT, "quit" }, 81 | { UCM_UNKNOWN, NULL } 82 | }; 83 | 84 | static void alsaucm_test_cmd_svr(void) 85 | { 86 | int fd; 87 | ssize_t read_count; 88 | char cmdstr[256] = {'\0'}; 89 | char ch; 90 | char *exit_str = "quit"; 91 | 92 | if (mknod("/data/alsaucm_test", S_IFIFO | 0666, 0) == 0) { 93 | fd = open("/data/alsaucm_test", O_RDONLY); 94 | while (1) { 95 | read_count = read(fd, &ch, 1); 96 | if (read_count == 0) { 97 | sleep(2); 98 | continue; 99 | } else if (read_count < 0) { 100 | fprintf(stderr, "alsaucm_test: error reading cmd\n"); 101 | break; 102 | } 103 | 104 | if (ch != '\n') { 105 | strlcat(cmdstr, &ch , (2+strlen(cmdstr))); 106 | continue; 107 | } else { 108 | if (!strncmp(cmdstr, exit_str, strlen(cmdstr))) { 109 | /* free UCM instace */ 110 | if (uc_mgr) { 111 | snd_use_case_mgr_close(uc_mgr); 112 | uc_mgr = NULL; 113 | } 114 | break; 115 | } else { 116 | process_cmd(cmdstr); 117 | memset(cmdstr, 0, sizeof(cmdstr)); 118 | } 119 | } 120 | } 121 | printf("alsaucm_test: exit server mode\n"); 122 | close(fd); 123 | remove("/data/alsaucm_test"); 124 | } else { 125 | fprintf(stderr, "alsaucm_test: Failed to create server\n"); 126 | } 127 | } 128 | 129 | 130 | static void print_help_menu(void) 131 | { 132 | printf("\nAvailable commands:\n" 133 | " open NAME open card NAME\n" 134 | " reset reset sound card to default state\n" 135 | " reload reload configuration\n" 136 | " listcards list available cards\n" 137 | " list IDENTIFIER list command\n" 138 | " get IDENTIFIER get string value\n" 139 | " geti IDENTIFIER get integer value\n" 140 | " set IDENTIFIER VALUE set string value\n" 141 | " help help\n" 142 | " quit quit\n"); 143 | } 144 | 145 | int main(int argc, char **argv) 146 | { 147 | char *help_str = "help"; 148 | argc--; 149 | argv++; 150 | 151 | if (argc > 0) { 152 | if (!strncmp(argv[0], help_str, strlen(argv[0]))) 153 | print_help_menu(); 154 | } else 155 | alsaucm_test_cmd_svr(); 156 | return 0; 157 | } 158 | 159 | static int process_cmd(char *cmdStr) 160 | { 161 | const char **list = NULL , *str = NULL; 162 | long lval; 163 | int err, i; 164 | char *command = NULL; 165 | int count = 0; 166 | char *identifier = NULL, *value = NULL; 167 | struct cmd *cmd = NULL; 168 | 169 | command = strtok_r(cmdStr, " ", &value); 170 | identifier = strtok_r(NULL, " ", &value); 171 | 172 | if (command == NULL) { 173 | fprintf(stderr, "NULL pointer encountered. Invalid value for command"); 174 | return -1; 175 | } 176 | 177 | for (cmd = cmds; cmd->cmd_str != NULL; cmd++) { 178 | if (strncmp(cmd->cmd_str, command, strlen(cmd->cmd_str)) == 0) 179 | break; 180 | } 181 | 182 | if (cmd->cmd_str == NULL) { 183 | fprintf(stderr, "Unknown command '%s'\n", command); 184 | return -EINVAL; 185 | } 186 | 187 | if ((identifier == NULL) && ((cmd->code != UCM_HELP) && 188 | (cmd->code != UCM_LISTCARDS) && (cmd->code != UCM_RESET) && 189 | (cmd->code != UCM_RELOAD))) 190 | { 191 | fprintf(stderr, "NULL pointer encountered. Invalid value for identifier"); 192 | return -1; 193 | } 194 | 195 | switch (cmd->code) { 196 | case UCM_HELP: 197 | print_help_menu(); 198 | break; 199 | 200 | case UCM_OPEN: 201 | if (uc_mgr) { 202 | snd_use_case_mgr_close(uc_mgr); 203 | uc_mgr = NULL; 204 | } 205 | 206 | err = snd_use_case_mgr_open(&uc_mgr, identifier); 207 | if (err < 0) { 208 | fprintf(stderr, "%s: error failed to open sound card %s: %d\n", cmd->cmd_str, identifier, err); 209 | return err; 210 | } 211 | snd_use_case_mgr_wait_for_parsing(uc_mgr); 212 | break; 213 | 214 | case UCM_LISTCARDS: 215 | err = snd_use_case_card_list(&list); 216 | if (err < 0) { 217 | fprintf(stderr, "%s: error failed to get card list: %d\n", cmd->cmd_str, err); 218 | return err; 219 | } 220 | if (err == 0) { 221 | printf("list is empty\n"); 222 | return 0; 223 | } 224 | 225 | for (i = 0; i < err; i++) 226 | printf(" %i: %s\n", i+1, list[i]); 227 | snd_use_case_free_list(list, err); 228 | break; 229 | 230 | case UCM_RESET: 231 | if (!uc_mgr) { 232 | fprintf(stderr, "No card is opened before. %s command can't be executed\n", cmd->cmd_str); 233 | return -EINVAL; 234 | } 235 | 236 | err = snd_use_case_mgr_reset(uc_mgr); 237 | if (err < 0) { 238 | fprintf(stderr, "%s: error failed to reset sound card %d\n", cmd->cmd_str, err); 239 | return err; 240 | } 241 | break; 242 | 243 | case UCM_RELOAD: 244 | if (!uc_mgr) { 245 | fprintf(stderr, "No card is opened before. %s command can't be executed\n", cmd->cmd_str); 246 | return -EINVAL; 247 | } 248 | 249 | err = snd_use_case_mgr_reload(uc_mgr); 250 | if (err < 0) { 251 | fprintf(stderr, "%s: error failed to reload manager %d\n", cmd->cmd_str, err); 252 | return err; 253 | } 254 | break; 255 | 256 | case UCM_LIST: 257 | if (!uc_mgr) { 258 | fprintf(stderr, "No card is opened before. %s command can't be executed\n", cmd->cmd_str); 259 | return -EINVAL; 260 | } 261 | 262 | err = snd_use_case_get_list(uc_mgr, identifier, &list); 263 | if (err < 0) { 264 | fprintf(stderr, "%s: error failed to get list %s: %d\n", cmd->cmd_str, identifier, err); 265 | return err; 266 | } 267 | if (err == 0) { 268 | printf("list is empty\n"); 269 | return 0; 270 | } 271 | for (i = 0; i < err; i++) { 272 | printf(" %i: %s\n", i+1, list[i]); 273 | } 274 | snd_use_case_free_list(list, err); 275 | break; 276 | 277 | case UCM_SET: 278 | if (!uc_mgr) { 279 | fprintf(stderr, "No card is opened before. %s command can't be executed\n", cmd->cmd_str); 280 | return -EINVAL; 281 | } 282 | 283 | err = snd_use_case_set(uc_mgr, identifier, value); 284 | if (err < 0) { 285 | fprintf(stderr, "%s: error failed to set %s=%s: %d\n", cmd->cmd_str, identifier, value, err); 286 | return err; 287 | } 288 | break; 289 | 290 | case UCM_GET: 291 | if (!uc_mgr) { 292 | fprintf(stderr, "No card is opened before. %s command can't be executed\n", cmd->cmd_str); 293 | return -EINVAL; 294 | } 295 | 296 | err = snd_use_case_get(uc_mgr, identifier, &str); 297 | if (err < 0) { 298 | fprintf(stderr, "%s: error failed to get %s: %d\n", cmd->cmd_str, identifier, err); 299 | return err; 300 | } 301 | printf(" %s=%s\n", identifier, str); 302 | free((void *)str); 303 | break; 304 | 305 | case UCM_GETI: 306 | if (!uc_mgr) { 307 | fprintf(stderr, "No card is opened before. %s command can't be executed\n", cmd->cmd_str); 308 | return -EINVAL; 309 | } 310 | 311 | err = snd_use_case_geti(uc_mgr, identifier, &lval); 312 | if (err < 0) { 313 | fprintf(stderr, "%s: error failed to get integer %s: %d\n", cmd->cmd_str, identifier, err); 314 | return lval; 315 | } 316 | printf(" %s=%li\n", identifier, lval); 317 | break; 318 | 319 | default: 320 | break; 321 | } 322 | return 0; 323 | } 324 | 325 | -------------------------------------------------------------------------------- /hal/msm8916/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2013 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef QCOM_AUDIO_PLATFORM_H 19 | #define QCOM_AUDIO_PLATFORM_H 20 | 21 | enum { 22 | FLUENCE_NONE, 23 | FLUENCE_DUAL_MIC = 0x1, 24 | FLUENCE_QUAD_MIC = 0x2, 25 | }; 26 | 27 | enum { 28 | FLUENCE_ENDFIRE = 0x1, 29 | FLUENCE_BROADSIDE = 0x2, 30 | }; 31 | 32 | /* 33 | * Below are the devices for which is back end is same, SLIMBUS_0_RX. 34 | * All these devices are handled by the internal HW codec. We can 35 | * enable any one of these devices at any time. An exception here is 36 | * 44.1k headphone which uses different backend. This is filtered 37 | * as different hal internal device in the code but remains same 38 | * as standard android device AUDIO_DEVICE_OUT_WIRED_HEADPHONE 39 | * for other layers. 40 | */ 41 | #define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \ 42 | (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \ 43 | AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE|\ 44 | AUDIO_DEVICE_OUT_LINE) 45 | 46 | /* Sound devices specific to the platform 47 | * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound 48 | * devices to enable corresponding mixer paths 49 | */ 50 | enum { 51 | SND_DEVICE_NONE = 0, 52 | 53 | /* Playback devices */ 54 | SND_DEVICE_MIN, 55 | SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN, 56 | SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN, 57 | SND_DEVICE_OUT_SPEAKER, 58 | SND_DEVICE_OUT_SPEAKER_REVERSE, 59 | SND_DEVICE_OUT_SPEAKER_SAFE, 60 | SND_DEVICE_OUT_LINE, 61 | SND_DEVICE_OUT_HEADPHONES, 62 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, 63 | SND_DEVICE_OUT_SPEAKER_AND_LINE, 64 | SND_DEVICE_OUT_VOICE_HANDSET, 65 | SND_DEVICE_OUT_VOICE_HAC_HANDSET, 66 | SND_DEVICE_OUT_VOICE_SPEAKER, 67 | SND_DEVICE_OUT_VOICE_SPEAKER_HFP, 68 | SND_DEVICE_OUT_VOICE_HEADPHONES, 69 | SND_DEVICE_OUT_VOICE_HEADSET, 70 | SND_DEVICE_OUT_VOICE_LINE, 71 | SND_DEVICE_OUT_HDMI, 72 | SND_DEVICE_OUT_SPEAKER_AND_HDMI, 73 | SND_DEVICE_OUT_BT_SCO, 74 | SND_DEVICE_OUT_BT_SCO_WB, 75 | SND_DEVICE_OUT_BT_A2DP, 76 | SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP, 77 | SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP, 78 | SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES, 79 | SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES, 80 | SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET, 81 | SND_DEVICE_OUT_VOICE_TX, 82 | SND_DEVICE_OUT_VOICE_MUSIC_TX, 83 | SND_DEVICE_OUT_AFE_PROXY, 84 | SND_DEVICE_OUT_USB_HEADSET, 85 | SND_DEVICE_OUT_USB_HEADPHONES, 86 | SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET, 87 | SND_DEVICE_OUT_ANC_HEADSET, 88 | SND_DEVICE_OUT_ANC_FB_HEADSET, 89 | SND_DEVICE_OUT_VOICE_ANC_HEADSET, 90 | SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET, 91 | SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET, 92 | SND_DEVICE_OUT_ANC_HANDSET, 93 | SND_DEVICE_OUT_SPEAKER_PROTECTED, 94 | SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED, 95 | SND_DEVICE_OUT_VOICE_USB_HEADSET, 96 | SND_DEVICE_OUT_VOICE_USB_HEADPHONES, 97 | SND_DEVICE_OUT_END, 98 | 99 | /* 100 | * Note: IN_BEGIN should be same as OUT_END because total number of devices 101 | * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices. 102 | */ 103 | /* Capture devices */ 104 | SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END, 105 | SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN, 106 | SND_DEVICE_IN_HANDSET_MIC_EXTERNAL, 107 | SND_DEVICE_IN_HANDSET_MIC_AEC, 108 | SND_DEVICE_IN_HANDSET_MIC_NS, 109 | SND_DEVICE_IN_HANDSET_MIC_AEC_NS, 110 | SND_DEVICE_IN_HANDSET_DMIC, 111 | SND_DEVICE_IN_HANDSET_DMIC_AEC, 112 | SND_DEVICE_IN_HANDSET_DMIC_NS, 113 | SND_DEVICE_IN_HANDSET_DMIC_AEC_NS, 114 | SND_DEVICE_IN_SPEAKER_MIC, 115 | SND_DEVICE_IN_SPEAKER_MIC_AEC, 116 | SND_DEVICE_IN_SPEAKER_MIC_NS, 117 | SND_DEVICE_IN_SPEAKER_MIC_AEC_NS, 118 | SND_DEVICE_IN_SPEAKER_DMIC, 119 | SND_DEVICE_IN_SPEAKER_DMIC_AEC, 120 | SND_DEVICE_IN_SPEAKER_DMIC_NS, 121 | SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS, 122 | SND_DEVICE_IN_HEADSET_MIC, 123 | SND_DEVICE_IN_HEADSET_MIC_FLUENCE, 124 | SND_DEVICE_IN_VOICE_SPEAKER_MIC, 125 | SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP, 126 | SND_DEVICE_IN_VOICE_HEADSET_MIC, 127 | SND_DEVICE_IN_HDMI_MIC, 128 | SND_DEVICE_IN_BT_SCO_MIC, 129 | SND_DEVICE_IN_BT_SCO_MIC_NREC, 130 | SND_DEVICE_IN_BT_SCO_MIC_WB, 131 | SND_DEVICE_IN_BT_SCO_MIC_WB_NREC, 132 | SND_DEVICE_IN_CAMCORDER_MIC, 133 | SND_DEVICE_IN_VOICE_DMIC, 134 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC, 135 | SND_DEVICE_IN_VOICE_SPEAKER_QMIC, 136 | SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC, 137 | SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC, 138 | SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC, 139 | SND_DEVICE_IN_VOICE_REC_MIC, 140 | SND_DEVICE_IN_VOICE_REC_MIC_NS, 141 | SND_DEVICE_IN_VOICE_REC_DMIC_STEREO, 142 | SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE, 143 | SND_DEVICE_IN_VOICE_RX, 144 | SND_DEVICE_IN_USB_HEADSET_MIC, 145 | SND_DEVICE_IN_CAPTURE_FM, 146 | SND_DEVICE_IN_AANC_HANDSET_MIC, 147 | SND_DEVICE_IN_QUAD_MIC, 148 | SND_DEVICE_IN_HANDSET_STEREO_DMIC, 149 | SND_DEVICE_IN_SPEAKER_STEREO_DMIC, 150 | SND_DEVICE_IN_CAPTURE_VI_FEEDBACK, 151 | SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE, 152 | SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE, 153 | SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE, 154 | SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE, 155 | SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE, 156 | SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC, 157 | SND_DEVICE_IN_HANDSET_QMIC, 158 | SND_DEVICE_IN_SPEAKER_QMIC_AEC, 159 | SND_DEVICE_IN_SPEAKER_QMIC_NS, 160 | SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS, 161 | SND_DEVICE_IN_END, 162 | 163 | SND_DEVICE_MAX = SND_DEVICE_IN_END, 164 | 165 | }; 166 | 167 | #define DEFAULT_OUTPUT_SAMPLING_RATE 48000 168 | #define DEFAULT_INPUT_SAMPLING_RATE 48000 169 | 170 | #define ALL_SESSION_VSID 0xFFFFFFFF 171 | #define DEFAULT_MUTE_RAMP_DURATION_MS 20 172 | #define DEFAULT_VOLUME_RAMP_DURATION_MS 20 173 | #define MIXER_PATH_MAX_LENGTH 100 174 | 175 | #define MAX_VOL_INDEX 5 176 | #define MIN_VOL_INDEX 0 177 | #define percent_to_index(val, min, max) \ 178 | ((val) * ((max) - (min)) * 0.01 + (min) + .5) 179 | 180 | /* 181 | * tinyAlsa library interprets period size as number of frames 182 | * one frame = channel_count * sizeof (pcm sample) 183 | * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes 184 | * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes 185 | * We should take care of returning proper size when AudioFlinger queries for 186 | * the buffer size of an input/output stream 187 | */ 188 | #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 1920 189 | #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 2 190 | #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240 191 | #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2 192 | 193 | #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 194 | #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 195 | #define LOW_LATENCY_CAPTURE_USE_CASE 1 196 | 197 | #define HDMI_MULTI_PERIOD_SIZE 336 198 | #define HDMI_MULTI_PERIOD_COUNT 8 199 | #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6 200 | #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2) 201 | 202 | #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 203 | #define AUDIO_CAPTURE_PERIOD_COUNT 2 204 | 205 | #define VOIP_CAPTURE_PERIOD_DURATION_MSEC 20 206 | #define VOIP_CAPTURE_PERIOD_COUNT 2 207 | 208 | #define VOIP_PLAYBACK_PERIOD_DURATION_MSEC 20 209 | #define VOIP_PLAYBACK_PERIOD_COUNT 2 210 | 211 | #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 212 | #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 213 | #define LOW_LATENCY_CAPTURE_USE_CASE 1 214 | 215 | #define DEVICE_NAME_MAX_SIZE 128 216 | #define HW_INFO_ARRAY_MAX_SIZE 32 217 | 218 | #define DEEP_BUFFER_PCM_DEVICE 0 219 | #define AUDIO_RECORD_PCM_DEVICE 0 220 | #define MULTIMEDIA2_PCM_DEVICE 1 221 | #define MULTIMEDIA3_PCM_DEVICE 4 222 | #define FM_PLAYBACK_PCM_DEVICE 5 223 | #define FM_CAPTURE_PCM_DEVICE 6 224 | #define HFP_PCM_RX 5 225 | #define HFP_SCO_RX 17 226 | #define HFP_ASM_RX_TX 18 227 | 228 | #define INCALL_MUSIC_UPLINK_PCM_DEVICE 1 229 | #define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16 230 | #define SPKR_PROT_CALIB_RX_PCM_DEVICE 5 231 | #define SPKR_PROT_CALIB_TX_PCM_DEVICE 26 232 | #define PLAYBACK_OFFLOAD_DEVICE 9 233 | #define PLAYBACK_OFFLOAD_DEVICE2 24 234 | 235 | /* Define macro for Internal FM volume mixer */ 236 | #define FM_RX_VOLUME "Internal FM RX Volume" 237 | 238 | #define LOWLATENCY_PCM_DEVICE 12 239 | #define EC_REF_RX "I2S_RX" 240 | 241 | #define VOICE_CALL_PCM_DEVICE 2 242 | #define VOICE2_CALL_PCM_DEVICE 13 243 | #define VOLTE_CALL_PCM_DEVICE 15 244 | #define QCHAT_CALL_PCM_DEVICE 26 245 | #define QCHAT_CALL_PCM_DEVICE_OF_EXT_CODEC 28 246 | #define VOWLAN_CALL_PCM_DEVICE 16 247 | 248 | #define AFE_PROXY_PLAYBACK_PCM_DEVICE 7 249 | #define AFE_PROXY_RECORD_PCM_DEVICE 8 250 | 251 | #define AUDIO_MAKE_STRING_FROM_ENUM(X) { #X, X } 252 | 253 | #define TX_VOICE_FLUENCE_PROV2 0x10F17 254 | #define TX_VOICE_DM_FV5_BROADSIDE 0x10F18 255 | #define TX_VOICE_FV5ECNS_SM 0x10F09 256 | #define TX_VOICE_FV5ECNS_DM 0x10F0A 257 | 258 | #define LIB_CSD_CLIENT "libcsd-client.so" 259 | /* CSD-CLIENT related functions */ 260 | typedef int (*init_t)(); 261 | typedef int (*deinit_t)(); 262 | typedef int (*disable_device_t)(); 263 | typedef int (*enable_device_config_t)(int, int); 264 | typedef int (*enable_device_t)(int, int, uint32_t); 265 | typedef int (*volume_t)(uint32_t, int, uint16_t); 266 | typedef int (*mic_mute_t)(uint32_t, int, uint16_t); 267 | typedef int (*slow_talk_t)(uint32_t, uint8_t); 268 | typedef int (*start_voice_t)(uint32_t); 269 | typedef int (*stop_voice_t)(uint32_t); 270 | typedef int (*start_playback_t)(uint32_t); 271 | typedef int (*stop_playback_t)(uint32_t); 272 | typedef int (*start_record_t)(uint32_t, int); 273 | typedef int (*stop_record_t)(uint32_t); 274 | /* CSD Client structure */ 275 | struct csd_data { 276 | void *csd_client; 277 | init_t init; 278 | deinit_t deinit; 279 | disable_device_t disable_device; 280 | enable_device_config_t enable_device_config; 281 | enable_device_t enable_device; 282 | volume_t volume; 283 | mic_mute_t mic_mute; 284 | slow_talk_t slow_talk; 285 | start_voice_t start_voice; 286 | stop_voice_t stop_voice; 287 | start_playback_t start_playback; 288 | stop_playback_t stop_playback; 289 | start_record_t start_record; 290 | stop_record_t stop_record; 291 | }; 292 | 293 | #define PLATFORM_INFO_XML_PATH "audio_platform_info.xml" 294 | #define PLATFORM_INFO_XML_BASE_STRING "audio_platform_info" 295 | 296 | #endif // QCOM_AUDIO_PLATFORM_H 297 | -------------------------------------------------------------------------------- /visualizer/NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2013, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | --------------------------------------------------------------------------------