2023-10-01 04:24:30 +00:00
|
|
|
{ alsa-ucm-conf
|
|
|
|
, lib
|
|
|
|
, preferEarpiece ? false
|
|
|
|
}:
|
2023-06-01 09:19:45 +00:00
|
|
|
alsa-ucm-conf.overrideAttrs (upstream: {
|
|
|
|
# upstream alsa ships with PinePhone audio configs, but they don't actually produce sound.
|
|
|
|
# see: <https://github.com/alsa-project/alsa-ucm-conf/pull/134>
|
|
|
|
# these audio files come from some revision of:
|
|
|
|
# - <https://gitlab.manjaro.org/manjaro-arm/packages/community/phosh/alsa-ucm-pinephone>
|
|
|
|
#
|
|
|
|
# alternative to patching is to plumb `ALSA_CONFIG_UCM2 = "${./ucm2}"` environment variable into the relevant places
|
|
|
|
# e.g. `systemd.services.pulseaudio.environment`.
|
|
|
|
# that leaves more opportunity for gaps (i.e. missing a service),
|
2023-06-01 21:13:44 +00:00
|
|
|
# on the other hand this method causes about 500 packages to be rebuilt (including qt5 and webkitgtk).
|
2023-06-01 09:19:45 +00:00
|
|
|
#
|
|
|
|
# note that with these files, the following audio device support:
|
|
|
|
# - headphones work.
|
|
|
|
# - "internal earpiece" works.
|
2023-09-13 09:35:01 +00:00
|
|
|
# - "internal speaker" doesn't work (but that's probably because i broke the ribbon cable)
|
2023-06-01 09:19:45 +00:00
|
|
|
# - "analog output" doesn't work.
|
2023-10-01 04:24:30 +00:00
|
|
|
postPatch = (upstream.postPatch or "") + ''
|
2023-06-01 09:19:45 +00:00
|
|
|
cp ${./ucm2/PinePhone}/* ucm2/Allwinner/A64/PinePhone/
|
2023-09-13 09:35:01 +00:00
|
|
|
|
2023-06-01 09:19:45 +00:00
|
|
|
# fix the self-contained ucm files i source from to have correct path within the alsa-ucm-conf source tree
|
2023-09-13 09:35:01 +00:00
|
|
|
substituteInPlace ucm2/Allwinner/A64/PinePhone/PinePhone.conf \
|
|
|
|
--replace 'HiFi.conf' '/Allwinner/A64/PinePhone/HiFi.conf'
|
|
|
|
substituteInPlace ucm2/Allwinner/A64/PinePhone/PinePhone.conf \
|
2023-10-01 04:24:30 +00:00
|
|
|
--replace 'VoiceCall.conf' '/Allwinner/A64/PinePhone/VoiceCall.conf'
|
|
|
|
'' + lib.optionalString preferEarpiece ''
|
|
|
|
# decrease the priority of the internal speaker so that sounds are routed
|
|
|
|
# to the earpiece by default.
|
|
|
|
# this is just personal preference.
|
2023-09-13 09:35:01 +00:00
|
|
|
substituteInPlace ucm2/Allwinner/A64/PinePhone/* \
|
|
|
|
--replace 'PlaybackPriority 300' 'PlaybackPriority 100'
|
2023-06-01 09:19:45 +00:00
|
|
|
'';
|
|
|
|
})
|