Commit Graph

29 Commits

Author SHA1 Message Date
Konsta
f67ec7ddb5 audio: build apex hal
* Update audio policy configuration based on cuttlefish [1] & [2].
* Update product package and copy file definitions to build the new APEX
  HAL instead of the legacy HAL.
* Update to system properties used in the new AIDL HAL.
* Use stub to simulate input as Raspberry Pi doesn't have any built-in
  hardware for audio input. It's still required to have primary input
  defined in audio policy config for many applications to function.

[1]: https://android.googlesource.com/device/google/cuttlefish/+/refs/tags/android-16.0.0_r1/shared/config/audio/policy/audio_policy_configuration.xml
[2]: https://android.googlesource.com/device/google/cuttlefish/+/refs/tags/android-16.0.0_r1/shared/config/audio/policy/primary_audio_policy_configuration.xml
2025-11-06 13:11:12 +02:00
Konsta
dcad73115c audio: hook refine position to alsa stream
* Fixes audio syncronization during video playback.
* Account start_threshold as device specific latency for ALSA HDMI and
  tinyalsa [1] (3.5mm jack, DAC & USB) output.
* Remove unneeded pcm call to query buffer size.

[1]: https://android.googlesource.com/platform/external/tinyalsa_new/+/refs/tags/android-16.0.0_r1/include/tinyalsa/pcm.h#214
2025-11-06 13:10:29 +02:00
Konsta
688b88189e audio: probe pcm card from property
* Valid values for the audio device property are 'jack', 'hdmi0', 'hdmi1',
  and 'dac'.
* If 'jack' is selected, first PCM card with name 'Headphones' is used.
  If 'dac' is selected, first PCM card that doesn't match the name for 3.5mm
  or HDMI devices is used. HDMI audio uses virtual ALSA devices instead of
  using tinyalsa to open a PCM card directly.
* Allow forcing specific PCM card for debugging/development purposes.
* PCM card numbers are different between Pi 4 and Pi 5 and order can change
  depending on the DAC driver that's enabled.

Pi 4:

console:/ # cat /proc/asound/cards
 0 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones
 1 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 2 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1
Pi 5 with DAC:

console:/ # cat /proc/asound/cards
 0 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 1 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1
 2 [sndrpihifiberry]: HifiberryDacp - snd_rpi_hifiberry_dacplus
                      snd_rpi_hifiberry_dacplus
2025-11-06 13:10:19 +02:00
Konsta
7bc0df0800 audio: alsa_utils: get hdmi device from property
* ALSA HDMI audio needs to be disabled when 3.5mm jack, DAC, or external
  USB audio cards is used. Enable HDMI audio path based on system property
  and the set the vc4 audio device name accordingly.
2025-11-06 13:10:09 +02:00
Konsta
fabdcf5490 audio: alsa_utils: increase start threshold to prevent underruns
* For some reason underruns are often observed when using the default
  parameters. Workaround this by increasing start threshold by 20 ms
  (i.e. at 48000Hz there's 960 additional frames in the ring buffer before
  the playback starts). Buffer size also needs to be increased to allow
  larger start threshold. Balance between avoiding underruns and adding
  latency.
* Add logging for the ALSA parameters.
2025-11-06 13:10:00 +02:00
Konsta
3ca268d760 audio: alsa_utils: use alsa for hdmi devices
* HDMI audio devices on Raspberry Pi use FORMAT_IEC958_SUBFRAME_LE which
  is not supported by tinyalsa used on Android. Use ALSA library and its
  virtual vc4 audio devices that use IEC958 plugin to manage the subframe
  conversion.
2025-11-06 13:09:49 +02:00
Konsta
3306b79d41 audio: alsa_utils: change log tag
* Match log tags used elsewhere in the audio HAL to make debugging easier
  (i.e. 'logcat | grep AHAL').
2025-11-06 13:09:39 +02:00
Konsta
5ad2f1d648 audio: alsa_utils: change default sample rate
* 48000Hz sample rate is set for output devices in audio policy
  configuration. Set the same default sample rate for sanity though this
  should not get used for valid profiles.
2025-11-06 13:09:27 +02:00
Konsta
c6340b9c67 audio: default to 48000Hz sample rate for usb 2025-11-06 13:09:12 +02:00
Guillaume LA ROQUE
9562ff31a8 audio: fix usb record
Default policy don't work with TI sound card due to some limitation.
Create and add usb audio policy xml file instead of copy default config
file.

Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
2025-11-06 13:09:01 +02:00
Guillaume LA ROQUE
7af9c78937 audio: enable usb audio hal
We compile source code to support USB audio devices but manifest not
enable it.
Uncomment usb module part to have USB audio device support.

Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
2025-11-06 13:08:51 +02:00
Konsta
a0f3530f2e audio: clean up makefiles
* Restructure to remove dependencies elsewhere in the AOSP tree, move APEX
  definition from subdirectory, 'bpfmt -s -w Andoid.bp', etc.
* Remove package license definitions that are not visible in this context.
2025-11-06 13:08:41 +02:00
Konsta
375a38c961 audio: rename hal for rpi 2025-11-06 13:08:31 +02:00
Konsta
451c17acd0 audio: remove effects and tests
* See [1] and [2] for reference and comments.

[1]: 346a56239e
[2]: 765b1a3a3d
2025-11-06 13:08:21 +02:00
Konsta
a76bafa9f4 audio: import usb audio configuration
* frameworks/av/services/audiopolicy/config/ at android-16.0.0_r1.
2025-11-06 13:08:12 +02:00
Konsta
487b7689f6 audio: import alsa_utils
* system/media/ at android-16.0.0_r1.
2025-11-06 13:08:00 +02:00
Konsta
7d6df38051 audio: import aidl hal
* hardware/interfaces/audio/aidl/default/ at android-16.0.0_r1.
2025-11-06 13:07:51 +02:00
Konsta
3292156c2a audio: remove legacy hal 2025-11-06 13:07:41 +02:00
Konsta
87e473d8ff audio: use vendor properties 2025-04-02 13:46:45 +03:00
Konsta
66f0ae7d82 audio: cache pcm card and device
* It's always been intended that changing audio output devices requires
  a reboot. Get the PCM card and device once when the HAL is initialized.
  Might save a few ms on start_output_stream.
2025-04-02 13:39:14 +03:00
Konsta
a6ff435674 hdmi audio: cache alsa device
* It's always been intended that changing audio output devices requires
  a reboot. Get the ALSA device once when the HAL is initialized.
  Might save a few ms on start_output_stream.
2025-04-02 13:39:00 +03:00
Konsta
d31cd0ab1c audio: proprietary -> vendor 2025-03-02 13:25:04 +02:00
Konsta
adc7d7b432 audio: minor code readability and formatting fixes
* Fixes 0205059ddb.
2024-11-22 12:53:15 +02:00
Konsta
06979db1ba audio: reduce id name size
* Fixes 0205059ddb.
2024-05-03 21:51:06 +03:00
Konsta
0205059ddb audio: probe pcm card for jack & dac 2023-11-23 17:32:53 +02:00
Konsta
ef056e1f91 hdmi audio: snake_case 2023-11-23 17:28:54 +02:00
Konsta
5aefdbab09 hdmi audio: remove local VC4 HDMI configuration
* This was updated in alsa-lib v1.2.7 so use the upstream config.
2023-03-12 17:39:51 +02:00
nename0
c6ecc0a1dd hdmi audio: add new audio HAL module with alsa instead of tinyalsa 2023-03-04 10:40:38 +02:00
Konsta
bbdbc45eea initial Raspberry Vanilla AOSP 12 commit
* Audio
  - Based on AOSP hikey audio HAL:
    https://android.googlesource.com/device/linaro/hikey/+/refs/heads/master/audio/
  - ALSA based on Android-x86
  - ALSA loop is used to support HDMI audio on Pi 4 because VC4 HDMI
    audio devices use SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE that is not
    supported on Android
    https://github.com/raspberrypi/linux/issues/4651
    https://github.com/raspberrypi/linux/issues/4654

* Bluetooth
  - AOSP Broadcom vendor stack with some additional fixes from android-rpi

* Camera
  - libcamera for official Raspberry Pi CSI camera modules based on GloDroid
  - AOSP external camera HAL for UVC USB webcams:
    https://source.android.com/docs/core/camera/external-usb-cameras

* Graphics
  - OpenGL & Vulkan: upstream Mesa with GloDroid patches
  - Upstream drm_hwcomposer with force resolution patch from Android-x86 and
    my additional fixes
  - minigbm based on GloDroid

* Health
  - Based on AOSP cuttlefish health HAL

* Kernel
  - Merge of Raspberry Pi and AOSP common kernel with my additional fixes
    and configurations
    https://github.com/raspberrypi/linux
    https://android.googlesource.com/kernel/common/

* Lights
  - Based on LineageOS Xiaomi msm8996-common lights HAL

* suspend_blocker
  - Based on AOSP cuttlefish

* v4l2_codec2
  - Based on AOSP with my Raspberry Pi 4 specific fixes

* Wifi
  - AOSP Broadcom vendor stack with my additional fixes
2022-09-17 13:57:57 +03:00