Skip to content

Commit

Permalink
audio: migrate back to yukawa HAL
Browse files Browse the repository at this point in the history
This does the initial move to the newly "generic" yukawa audio HAL.

The HAL supports loading the mixer_paths.xml file based on some runtime
property (vendor.hw), this is used for dragonboard where the db845c and
rb5 use the same lunch target. However because we use different lunch
targets I've hardcoded vendor.hw to "sdm845", the mixer_paths.xml is
packaged from the device specific directory to
/vendor/etc/mixer_paths.sdm845.xml.

This depends on a new patch to system/media/ to support specifying the
output device in the mixer paths xml file:
https://android-review.googlesource.com/c/platform/system/media/+/2036767

I'll update our local_manifests to include this change in the mean time
before it's merged.

The beryllium and axolotl mixer paths are basically placeholder and will
need to be fixed. The enchilada paths *should* work, but for some reason
the speaker is broken, I suspect a kernel issue here. Headphone
detection and auto-switching works, on enchilada I'm able to hear audio
through headphones.

Signed-off-by: Caleb Connolly <[email protected]>
  • Loading branch information
calebccff committed May 18, 2022
1 parent f9ce8ee commit 9bd7f5a
Show file tree
Hide file tree
Showing 22 changed files with 2,819 additions and 21 deletions.
2 changes: 2 additions & 0 deletions axolotl/axolotl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ BOARD_VENDOR_KERNEL_MODULES := $(filter $(VENDOR_KERN_MODS),$(KERNEL_MODS))
# All other modules go to ramdisk
BOARD_GENERIC_RAMDISK_KERNEL_MODULES := $(filter-out $(VENDOR_KERN_MODS),$(KERNEL_MODS))

BOARD_DIR := device/generic/sdm845/axolotl

# Inherit the full_base and device configurations
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
$(call inherit-product, device/generic/sdm845/axolotl/device.mk)
Expand Down
1 change: 0 additions & 1 deletion axolotl/device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
PRODUCT_COPY_FILES := \
$(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.axolotl \
$(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.axolotl \
device/generic/sdm845/shared/etc/audio.sdm845.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio.axolotl.xml \
device/generic/sdm845/shared/init.sdm845.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.axolotl.rc \
device/generic/sdm845/shared/init.sdm845.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.axolotl.usb.rc \
device/generic/sdm845/shared/key_layout.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/axolotl.kl
Expand Down
35 changes: 21 additions & 14 deletions shared/etc/mixer_paths.xml → axolotl/mixer_paths.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<mixer>
<!-- Enable Internal speaker -->
<ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia1" value="1" />
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia2' 1" />
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia2" value="1" />
<ctl name="MultiMedia3 Mixer SLIMBUS_0_TX" value="1" />
<ctl name="AIF1_CAP Mixer SLIM TX7" value="1" />
<ctl name="SLIM RX0 MUX" value="AIF1_PB" />
Expand All @@ -13,22 +13,23 @@
<ctl name="SLIM RX5 MUX" value="ZERO" />
<ctl name="SLIM RX6 MUX" value="ZERO" />
<ctl name="SLIM RX7 MUX" value="ZERO" />
<ctl name="RX INT7_1 MIX1 INP0" value="RX0" />
<ctl name="RX INT8_1 MIX1 INP0" value="RX1" />
<ctl name="AIF1_CAP Mixer SLIM TX0" value="1" />
<ctl name="RX INT7_1 MIX1 INP0" value="RX1" />
<ctl name="RX INT8_1 MIX1 INP0" value="RX2" />
<ctl name="RX INT1_2 MUX" value="RX0" />
<ctl name="RX INT2_2 MUX" value="RX1" />
<ctl name="CDC_IF TX7 MUX" value="DEC7" />
<ctl name="CDC_IF TX0 MUX" value="DEC0" />

<ctl name="COMP1 Switch" value="1" />
<ctl name="COMP2 Switch" value="1" />
<ctl name="COMP7 Switch" value="0" />
<ctl name="COMP8 Switch" value="0" />
<ctl name="COMP2 Switch" value="1" />
<ctl name="COMP7 Switch" value="0" />
<ctl name="COMP8 Switch" value="0" />

<!-- Default speaker -->
<ctl name="Amp DSP Switch" value="0" />
<!-- <ctl name="Amp DSP Switch" value="0" /> -->

<!-- Default headphones -->
<ctl name="RX INT1_1 MIX1 INP0" value="ZERO" />
<!-- <ctl name="RX INT1_1 MIX1 INP0" value="ZERO" />
<ctl name="RX INT2_1 MIX1 INP0" value="ZERO" />
<ctl name="RX INT1_1 INTERP" value="ZERO" />
<ctl name="RX INT2_1 INTERP" value="ZERO" />
Expand All @@ -37,10 +38,15 @@
<ctl name="COMP1 Switch" value="0" />
<ctl name="COMP2 Switch" value="0" />
<ctl name="RX1 Digital Volume" value="0" />
<ctl name="RX2 Digital Volume" value="0" />
<ctl name="RX2 Digital Volume" value="0" /> -->

<path name="speaker">
<ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia1" value="1" />
<ctl name="COMP7 Switch" value="1" />
<ctl name="COMP8 Switch" value="1" />
<ctl name="Amp DSP Switch" value="1" />
<ctl name="RX7 Digital Volume" value="84" />
<ctl name="RX8 Digital Volume" value="84" />
</path>

<path name="headset">
Expand All @@ -50,14 +56,15 @@
<ctl name="RX INT1_2 MUX" value="RX2" />
<ctl name="RX INT2_2 MUX" value="RX3" /> -->

<ctl name="RX INT1_1 MIX1 INP0" value="RX0" />
<!-- <ctl name="RX INT1_1 MIX1 INP0" value="RX0" />
<ctl name="RX INT2_1 MIX1 INP0" value="RX1" />
<ctl name="RX INT1_1 INTERP" value="RX INT1_1 MIX1" />
<ctl name="RX INT2_1 INTERP" value="RX INT2_1 MIX1" />
<ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX INT2 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX INT2_1 INTERP" value="RX INT2_1 MIX1" /> -->

<ctl name="COMP1 Switch" value="1" />
<ctl name="COMP2 Switch" value="1" />
<ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX INT2 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX1 Digital Volume" value="84" />
<ctl name="RX2 Digital Volume" value="84" />
</path>
Expand Down
2 changes: 2 additions & 0 deletions beryllium/beryllium.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ BOARD_VENDOR_KERNEL_MODULES := $(filter $(VENDOR_KERN_MODS),$(KERNEL_MODS))
# All other modules go to ramdisk
BOARD_GENERIC_RAMDISK_KERNEL_MODULES := $(filter-out $(VENDOR_KERN_MODS),$(KERNEL_MODS))

BOARD_DIR := device/generic/sdm845/beryllium

# Inherit the full_base and device configurations
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
$(call inherit-product, device/generic/sdm845/beryllium/device.mk)
Expand Down
7 changes: 6 additions & 1 deletion beryllium/device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
PRODUCT_COPY_FILES := \
$(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.beryllium \
$(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.beryllium \
device/generic/sdm845/shared/etc/audio.sdm845.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio.beryllium.xml \
device/generic/sdm845/shared/init.sdm845.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.beryllium.rc \
device/generic/sdm845/shared/init.sdm845.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.beryllium.usb.rc \
device/generic/sdm845/shared/key_layout.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/beryllium.kl
Expand All @@ -27,3 +26,9 @@ PRODUCT_PACKAGES := audio.primary.beryllium

# Build generic lights HAL
PRODUCT_PACKAGES += lights.beryllium

# FIXME: the DTS sets the sound card model to "Xiaomi Poco F1" but the kernel doesn't handle spaces
# in the sound card model very well...
# This might not even be correct
PRODUCT_PROPERTY_OVERRIDES += \
vendor.sound_card=F1
71 changes: 71 additions & 0 deletions beryllium/mixer_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<mixer>
<!-- Enable Internal speaker -->
<ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia1" value="1" />
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia2" value="1" />
<ctl name="MultiMedia3 Mixer SLIMBUS_0_TX" value="1" />
<ctl name="AIF1_CAP Mixer SLIM TX7" value="1" />
<ctl name="SLIM RX0 MUX" value="AIF1_PB" />
<ctl name="SLIM RX1 MUX" value="AIF1_PB" />
<ctl name="SLIM RX2 MUX" value="ZERO" />
<ctl name="SLIM RX3 MUX" value="ZERO" />
<ctl name="SLIM RX4 MUX" value="ZERO" />
<ctl name="SLIM RX5 MUX" value="ZERO" />
<ctl name="SLIM RX6 MUX" value="ZERO" />
<ctl name="SLIM RX7 MUX" value="ZERO" />
<ctl name="AIF1_CAP Mixer SLIM TX0" value="1" />
<ctl name="RX INT7_1 MIX1 INP0" value="RX1" />
<ctl name="RX INT8_1 MIX1 INP0" value="RX2" />
<ctl name="RX INT1_2 MUX" value="RX0" />
<ctl name="RX INT2_2 MUX" value="RX1" />
<ctl name="CDC_IF TX0 MUX" value="DEC0" />

<ctl name="COMP1 Switch" value="1" />
<ctl name="COMP2 Switch" value="1" />
<ctl name="COMP7 Switch" value="0" />
<ctl name="COMP8 Switch" value="0" />

<!-- Default speaker -->
<!-- <ctl name="Amp DSP Switch" value="0" /> -->

<!-- Default headphones -->
<!-- <ctl name="RX INT1_1 MIX1 INP0" value="ZERO" />
<ctl name="RX INT2_1 MIX1 INP0" value="ZERO" />
<ctl name="RX INT1_1 INTERP" value="ZERO" />
<ctl name="RX INT2_1 INTERP" value="ZERO" />
<ctl name="RX INT1 DEM MUX" value="NORMAL_DSM_OUT" />
<ctl name="RX INT2 DEM MUX" value="NORMAL_DSM_OUT" />
<ctl name="COMP1 Switch" value="0" />
<ctl name="COMP2 Switch" value="0" />
<ctl name="RX1 Digital Volume" value="0" />
<ctl name="RX2 Digital Volume" value="0" /> -->

<path name="speaker">
<ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia1" value="1" />
<ctl name="COMP7 Switch" value="1" />
<ctl name="COMP8 Switch" value="1" />
<ctl name="Amp DSP Switch" value="1" />
<ctl name="RX7 Digital Volume" value="84" />
<ctl name="RX8 Digital Volume" value="84" />
</path>

<path name="headset">
<!-- <ctl name="SLIM RX2 MUX" value="AIF4_PB" />
<ctl name="SLIM RX3 MUX" value="AIF4_PB" />
<ctl name="SLIM_6_RX Channels" value="Two" />
<ctl name="RX INT1_2 MUX" value="RX2" />
<ctl name="RX INT2_2 MUX" value="RX3" /> -->

<!-- <ctl name="RX INT1_1 MIX1 INP0" value="RX0" />
<ctl name="RX INT2_1 MIX1 INP0" value="RX1" />
<ctl name="RX INT1_1 INTERP" value="RX INT1_1 MIX1" />
<ctl name="RX INT2_1 INTERP" value="RX INT2_1 MIX1" /> -->

<ctl name="COMP1 Switch" value="1" />
<ctl name="COMP2 Switch" value="1" />
<ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX INT2 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX1 Digital Volume" value="84" />
<ctl name="RX2 Digital Volume" value="84" />
</path>
</mixer>
4 changes: 3 additions & 1 deletion enchilada/device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
PRODUCT_COPY_FILES := \
$(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.enchilada \
$(LOCAL_PATH)/fstab.ramdisk:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.enchilada \
device/generic/sdm845/shared/etc/audio.sdm845.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio.enchilada.xml \
device/generic/sdm845/shared/init.sdm845.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.enchilada.rc \
device/generic/sdm845/shared/init.sdm845.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.enchilada.usb.rc \
device/generic/sdm845/shared/key_layout.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/enchilada.kl
Expand All @@ -27,3 +26,6 @@ PRODUCT_PACKAGES := audio.primary.enchilada

# Build generic lights HAL
PRODUCT_PACKAGES += lights.enchilada

PRODUCT_PROPERTY_OVERRIDES += \
vendor.sound_card=OnePlus6
2 changes: 2 additions & 0 deletions enchilada/enchilada.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ BOARD_VENDOR_KERNEL_MODULES := $(filter $(VENDOR_KERN_MODS),$(KERNEL_MODS))
# All other modules go to ramdisk
BOARD_GENERIC_RAMDISK_KERNEL_MODULES := $(filter-out $(VENDOR_KERN_MODS),$(KERNEL_MODS))

BOARD_DIR := device/generic/sdm845/enchilada

# Inherit the full_base and device configurations
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
$(call inherit-product, device/generic/sdm845/enchilada/device.mk)
Expand Down
41 changes: 41 additions & 0 deletions enchilada/mixer_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<mixer>
<!-- MultiMedia 1 is the speaker -->
<ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia1" value="1" />
<!-- Multimedia 2 is for headphones(/earpiece?) -->
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia2" value="1" />
<ctl name="MultiMedia3 Mixer SLIMBUS_0_TX" value="1" />
<ctl name="AIF1_CAP Mixer SLIM TX7" value="1" />
<ctl name="CDC_IF TX7 MUX" value="DEC7" />
<ctl name="SLIM RX0 MUX" value="AIF1_PB" />
<ctl name="SLIM RX1 MUX" value="AIF1_PB" />
<ctl name="SLIM RX2 MUX" value="AIF1_PB" />
<ctl name="SLIM RX3 MUX" value="AIF1_PB" />
<ctl name="SLIM RX4 MUX" value="ZERO" />
<ctl name="SLIM RX5 MUX" value="ZERO" />
<ctl name="SLIM RX6 MUX" value="ZERO" />
<ctl name="SLIM RX7 MUX" value="ZERO" />
<ctl name="RX INT7_1 MIX1 INP0" value="RX0" />
<ctl name="RX INT8_1 MIX1 INP0" value="RX1" />
<ctl name="RX INT1_2 MUX" value="RX0" />
<ctl name="RX INT2_2 MUX" value="RX1" />

<!-- Headphones configuration, some of this maybe needed for speaker? -->
<ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX INT2 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="RX INT1_1 MIX1 INP0" value="RX2" />
<ctl name="RX INT2_1 MIX1 INP0" value="RX3" />
<ctl name="RX INT1_1 INTERP" value="RX INT1_1 MIX1" />
<ctl name="RX INT2_1 INTERP" value="RX INT2_1 MIX1" />
<!-- Earpiece volume, earpiece and headphones both use device 1
so the earpiece must be muted when headphones are selected
at least, that's the running theory -->
<ctl name="RX0 Digital Volume" value="0" />

<path name="speaker" device="0">
<ctl name="Amp DSP Switch" value="1" />
</path>

<path name="headset" device="1">
</path>
</mixer>
3 changes: 0 additions & 3 deletions shared/BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
# BT
BOARD_HAVE_BLUETOOTH := true

# TinyHAL
BOARD_USES_TINYHAL_AUDIO := true

BOARD_SEPOLICY_DIRS += \
device/generic/sdm845/shared/sepolicy \
system/bt/vendor_libs/linux/sepolicy
Expand Down
4 changes: 3 additions & 1 deletion shared/device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ PRODUCT_PROPERTY_OVERRIDES += \
ro.hardware.hwcomposer=drm \
debug.sf.no_hw_vsync=1 \
ro.sf.lcd_density=400 \
ro.opengles.version=196609
ro.opengles.version=196609 \
vendor.hw=sdm845

#
# Hardware Composer HAL
Expand Down Expand Up @@ -141,6 +142,7 @@ PRODUCT_PACKAGES += \
USE_XML_AUDIO_POLICY_CONF := 1
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/etc/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \
$(BOARD_DIR)/mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths.sdm845.xml \
$(LOCAL_PATH)/etc/audio_policy_configuration_bluetooth_legacy_hal.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration_bluetooth_legacy_hal.xml \
$(LOCAL_PATH)/etc/public.libraries.txt:$(TARGET_COPY_OUT_VENDOR)/etc/public.libraries.txt \
frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \
Expand Down
46 changes: 46 additions & 0 deletions shared/hals/audio/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH := $(call my-dir)

# The default audio HAL module, which is a stub, that is loaded if no other
# device specific modules are present. The exact load order can be seen in
# libhardware/hardware.c
#
# The format of the name is audio.<type>.<hardware/etc>.so where the only
# required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc.
include $(CLEAR_VARS)

LOCAL_HEADER_LIBRARIES += libhardware_headers
LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_VENDOR_MODULE := true

LOCAL_SRC_FILES := audio_hw.c \
audio_aec.c \
fifo_wrapper.cpp \
fir_filter.c
LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioroute \
libaudioutils
LOCAL_CFLAGS := -Wno-unused-parameter
LOCAL_C_INCLUDES += \
external/tinyalsa/include \
external/expat/lib \
$(call include-path-for, audio-route) \
system/media/audio_utils/include \
system/media/audio_effects/include

include $(BUILD_SHARED_LIBRARY)
Loading

0 comments on commit 9bd7f5a

Please sign in to comment.