From 0cc22952337b3980b817bb115216ec40174a2dc6 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 26 Sep 2022 03:47:35 -0700 Subject: [PATCH] moby: patch alsa instead of special-casing PinePhone config unfortunately, this forces us to recompile *everything* above alsa, without leveraging the nixos.org cache. several hours, and probably necessary after any nixpkgs update, so not super practical. --- machines/moby/default.nix | 9 -- machines/moby/ucm2/PinePhone/HiFi.conf | 148 ------------------- machines/moby/ucm2/PinePhone/PinePhone.conf | 11 -- machines/moby/ucm2/PinePhone/VoiceCall.conf | 153 -------------------- machines/moby/ucm2/ucm.conf | 8 - pkgs/alsa-ucm-conf/default.nix | 13 ++ pkgs/overlay.nix | 1 + 7 files changed, 14 insertions(+), 329 deletions(-) delete mode 100644 machines/moby/ucm2/PinePhone/HiFi.conf delete mode 100644 machines/moby/ucm2/PinePhone/PinePhone.conf delete mode 100644 machines/moby/ucm2/PinePhone/VoiceCall.conf delete mode 100644 machines/moby/ucm2/ucm.conf create mode 100644 pkgs/alsa-ucm-conf/default.nix diff --git a/machines/moby/default.nix b/machines/moby/default.nix index 97f7ab28..39c5242d 100644 --- a/machines/moby/default.nix +++ b/machines/moby/default.nix @@ -72,14 +72,5 @@ # enable rotation sensor hardware.sensor.iio.enable = true; - # from https://gitlab.manjaro.org/manjaro-arm/packages/community/phosh/alsa-ucm-pinephone - # mobile-nixos does this same thing, with *slightly different settings*. - # i trust manjaro more because the guy maintaining that is actively trying to upstream into alsa-ucm-conf. - # an alternative may be to build a custom alsa with the PinePhone config patch applied: - # - - # that would make this be not device-specific - environment.variables.ALSA_CONFIG_UCM2 = "${./ucm2}"; - systemd.services.pulseaudio.environment.ALSA_CONFIG_UCM2 = "${./ucm2}"; - users.groups.feedbackd.gid = config.sane.allocations.feedbackd-gid; } diff --git a/machines/moby/ucm2/PinePhone/HiFi.conf b/machines/moby/ucm2/PinePhone/HiFi.conf deleted file mode 100644 index a2432495..00000000 --- a/machines/moby/ucm2/PinePhone/HiFi.conf +++ /dev/null @@ -1,148 +0,0 @@ -SectionVerb { - EnableSequence [ - cset "name='Headphone Playback Switch' off" - cset "name='Headphone Source Playback Route' DAC" - cset "name='Line In Playback Switch' off" - cset "name='Line Out Playback Switch' off" - cset "name='Line Out Source Playback Route' Mono Differential" - cset "name='Mic1 Playback Switch' off" - cset "name='Mic2 Playback Switch' off" - cset "name='AIF1 DA0 Playback Volume' 160" - cset "name='AIF3 ADC Source Capture Route' None" - cset "name='AIF2 DAC Source Playback Route' AIF2" - cset "name='DAC Playback Switch' on" - cset "name='DAC Playback Volume' 160" - cset "name='ADC Digital DAC Playback Switch' off" - cset "name='AIF1 Slot 0 Digital DAC Playback Switch' on" - cset "name='AIF2 Digital DAC Playback Switch' off" - cset "name='DAC Reversed Playback Switch' off" - cset "name='Earpiece Playback Switch' off" - cset "name='Earpiece Source Playback Route' DACL" - - cset "name='Line In Capture Switch' off" - cset "name='Mic1 Capture Switch' off" - cset "name='Mic1 Boost Volume' 7" - cset "name='Mic2 Capture Switch' off" - cset "name='Mic2 Boost Volume' 7" - cset "name='Mixer Capture Switch' off" - cset "name='Mixer Reversed Capture Switch' off" - cset "name='ADC Capture Volume' 160" - cset "name='ADC Gain Capture Volume' 7" - cset "name='AIF1 AD0 Capture Volume' 160" - cset "name='AIF1 Data Digital ADC Capture Switch' on" - cset "name='AIF2 ADC Mixer ADC Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF1 DA0 Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF2 DAC Rev Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF1 DA0 Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF1 DA0 Capture Switch' off" - ] - - DisableSequence [ - ] - - Value { - } -} - -SectionDevice."Speaker" { - Comment "Internal speaker" - EnableSequence [ - cset "name='AIF1 DA0 Stereo Playback Route' Mix Mono" - cset "name='Line Out Playback Switch' on" - cset "name='Line Out Playback Volume' 100%" - ] - - DisableSequence [ - cset "name='Line Out Playback Switch' off" - ] - - Value { - PlaybackVolume "Line Out Playback Volume" - PlaybackSwitch "Line Out Playback Switch" - PlaybackChannels 2 - PlaybackPriority 300 - PlaybackPCM "hw:${CardId},0" - } -} -SectionDevice."Earpiece" { - Comment "Internal Earpiece" - EnableSequence [ - cset "name='AIF1 DA0 Stereo Playback Route' Mix Mono" - cset "name='Earpiece Playback Switch' on" - cset "name='Earpiece Playback Volume' 100%" - ] - - DisableSequence [ - cset "name='Earpiece Playback Switch' off" - ] - - Value { - PlaybackVolume "Earpiece Playback Volume" - PlaybackSwitch "Earpiece Playback Switch" - PlaybackChannels 2 - PlaybackPriority 200 - PlaybackPCM "hw:${CardId},0" - } -} -SectionDevice."Mic" { - Comment "Internal Microphone" - ConflictingDevice [ - "Headset" - ] - EnableSequence [ - cset "name='Mic1 Capture Switch' on" - ] - DisableSequence [ - cset "name='Mic1 Capture Switch' off" - ] - Value { - CapturePriority 100 - CapturePCM "hw:${CardId},0" - CaptureChannels 2 - CaptureMixerElem "ADC" - CaptureVolume "ADC Capture Volume" - CaptureSwitch "Mic1 Capture Switch" - } -} -SectionDevice."Headset" { - Comment "Headset Microphone" - ConflictingDevice [ - "Mic" - ] - EnableSequence [ - cset "name='Mic2 Capture Switch' on" - ] - DisableSequence [ - cset "name='Mic2 Capture Switch' off" - ] - Value { - CapturePriority 500 - CapturePCM "hw:${CardId},0" - CaptureChannels 2 - CaptureMixerElem "ADC" - CaptureVolume "ADC Capture Volume" - CaptureSwitch "Mic2 Capture Switch" - JackControl "Headset Microphone Jack" - } -} -SectionDevice."Headphones" { - Comment "Headphones" - EnableSequence [ - cset "name='AIF1 DA0 Stereo Playback Route' Stereo" - cset "name='Headphone Playback Switch' on" - cset "name='Headphone Playback Volume' 70%" - ] - - DisableSequence [ - cset "name='Headphone Playback Switch' off" - ] - - Value { - PlaybackVolume "Headphone Playback Volume" - PlaybackSwitch "Headphone Playback Switch" - PlaybackChannels 2 - PlaybackPriority 500 - PlaybackPCM "hw:${CardId},0" - JackControl "Headphone Jack" - } -} diff --git a/machines/moby/ucm2/PinePhone/PinePhone.conf b/machines/moby/ucm2/PinePhone/PinePhone.conf deleted file mode 100644 index 37412163..00000000 --- a/machines/moby/ucm2/PinePhone/PinePhone.conf +++ /dev/null @@ -1,11 +0,0 @@ -Syntax 2 - -SectionUseCase."HiFi" { - File "HiFi.conf" - Comment "Default" -} - -SectionUseCase."Voice Call" { - File "VoiceCall.conf" - Comment "Phone call" -} diff --git a/machines/moby/ucm2/PinePhone/VoiceCall.conf b/machines/moby/ucm2/PinePhone/VoiceCall.conf deleted file mode 100644 index 349ac8bd..00000000 --- a/machines/moby/ucm2/PinePhone/VoiceCall.conf +++ /dev/null @@ -1,153 +0,0 @@ -SectionVerb { - EnableSequence [ - cset "name='Headphone Playback Switch' off" - cset "name='Headphone Source Playback Route' DAC" - cset "name='Line In Playback Switch' off" - cset "name='Line Out Playback Switch' off" - cset "name='Line Out Source Playback Route' Mono Differential" - cset "name='Mic1 Playback Switch' off" - cset "name='Mic2 Playback Switch' off" - cset "name='AIF1 DA0 Playback Volume' 160" - cset "name='AIF2 DAC Playback Volume' 160" - cset "name='AIF3 ADC Source Capture Route' None" - cset "name='AIF2 DAC Source Playback Route' AIF2" - cset "name='DAC Playback Switch' on" - cset "name='DAC Playback Volume' 160" - cset "name='ADC Digital DAC Playback Switch' off" - cset "name='AIF1 Slot 0 Digital DAC Playback Switch' on" - cset "name='AIF2 Digital DAC Playback Switch' on" - cset "name='DAC Reversed Playback Switch' off" - cset "name='Earpiece Playback Switch' off" - cset "name='Earpiece Source Playback Route' DACL" - - cset "name='Line In Capture Switch' off" - cset "name='Mic1 Capture Switch' off" - cset "name='Mic1 Boost Volume' 0" - cset "name='Mic1 Playback Volume' 7" - cset "name='Mic2 Capture Switch' off" - cset "name='Mic2 Boost Volume' 0" - cset "name='Mic2 Playback Volume' 7" - cset "name='Mixer Capture Switch' off" - cset "name='Mixer Reversed Capture Switch' off" - cset "name='ADC Capture Volume' 160" - cset "name='ADC Gain Capture Volume' 7" - cset "name='AIF1 AD0 Capture Volume' 160" - cset "name='AIF1 Data Digital ADC Capture Switch' on" - cset "name='AIF2 ADC Capture Volume' 160" - cset "name='AIF2 ADC Mixer ADC Capture Switch' on" - cset "name='AIF2 ADC Mixer AIF1 DA0 Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF2 DAC Rev Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF1 DA0 Capture Switch' off" - cset "name='AIF2 ADC Mixer AIF1 DA0 Capture Switch' off" - ] - - DisableSequence [ - ] - - Value { - PlaybackRate 8000 - } -} - -SectionDevice."Speaker" { - Comment "Internal speaker" - EnableSequence [ - cset "name='AIF1 DA0 Stereo Playback Route' Mix Mono" - cset "name='Line Out Playback Switch' on" - cset "name='Line Out Playback Volume' 100%" - ] - - DisableSequence [ - cset "name='Line Out Playback Switch' off" - ] - - Value { - PlaybackVolume "Line Out Playback Volume" - PlaybackSwitch "Line Out Playback Switch" - PlaybackChannels 2 - PlaybackPriority 300 - PlaybackPCM "hw:${CardId},0" - } -} -SectionDevice."Earpiece" { - Comment "Internal Earpiece" - EnableSequence [ - cset "name='AIF1 DA0 Stereo Playback Route' Mix Mono" - cset "name='Earpiece Playback Switch' on" - cset "name='Earpiece Playback Volume' 100%" - ] - - DisableSequence [ - cset "name='Earpiece Playback Switch' off" - ] - - Value { - PlaybackVolume "Earpiece Playback Volume" - PlaybackSwitch "Earpiece Playback Switch" - PlaybackChannels 2 - PlaybackPriority 500 - PlaybackPCM "hw:${CardId},0" - } -} -SectionDevice."Mic" { - Comment "Internal Microphone" - ConflictingDevice [ - "Headset" - ] - EnableSequence [ - cset "name='Mic1 Capture Switch' on" - ] - DisableSequence [ - cset "name='Mic1 Capture Switch' off" - ] - Value { - CapturePriority 200 - CapturePCM "hw:${CardId},0" - CaptureMixerElem "ADC" - CaptureVolume "ADC Capture Volume" - CaptureSwitch "Mic1 Capture Switch" - CaptureChannels 2 - } -} -SectionDevice."Headset" { - Comment "Headset Microphone" - ConflictingDevice [ - "Mic" - ] - EnableSequence [ - cset "name='Mic2 Capture Switch' on" - ] - DisableSequence [ - cset "name='Mic2 Capture Switch' off" - ] - Value { - CapturePriority 500 - CapturePCM "hw:${CardId},0" - CaptureChannels 2 - CaptureMixerElem "ADC" - CaptureVolume "ADC Capture Volume" - CaptureSwitch "Mic2 Capture Switch" - JackControl "Headset Microphone Jack" - } -} -SectionDevice."Headphones" { - Comment "Headphones" - EnableSequence [ - cset "name='AIF1 DA0 Stereo Playback Route' Stereo" - cset "name='Headphone Playback Switch' on" - cset "name='Headphone Playback Volume' 100%" - ] - - DisableSequence [ - cset "name='Headphone Playback Switch' off" - ] - - Value { - PlaybackVolume "Headphone Playback Volume" - PlaybackSwitch "Headphone Playback Switch" - PlaybackChannels 2 - PlaybackPriority 500 - PlaybackPCM "hw:${CardId},0" - JackControl "Headphone Jack" - } -} diff --git a/machines/moby/ucm2/ucm.conf b/machines/moby/ucm2/ucm.conf deleted file mode 100644 index 1fd430f1..00000000 --- a/machines/moby/ucm2/ucm.conf +++ /dev/null @@ -1,8 +0,0 @@ -Syntax 3 - -UseCasePath { - legacy { - Directory "PinePhone" - File "PinePhone.conf" - } -} diff --git a/pkgs/alsa-ucm-conf/default.nix b/pkgs/alsa-ucm-conf/default.nix new file mode 100644 index 00000000..2b51c06a --- /dev/null +++ b/pkgs/alsa-ucm-conf/default.nix @@ -0,0 +1,13 @@ +{ pkgs }: + +(pkgs.alsa-ucm-conf.overrideAttrs (upstream: { + patches = (upstream.patches or []) ++ [ + (pkgs.fetchpatch { + # "Add UCM for PinePhone" + # we need this for audio to work on the Pinephone + url = "https://github.com/alsa-project/alsa-ucm-conf/pull/134.diff"; + sha256 = "sha256-hFpp8jQo8fQRqKrSnBEi5eh1Zf/x+1o+p40ML5iuWJM="; + }) + ]; +})) + diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index 4765ce4a..b44f35f3 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -21,6 +21,7 @@ }; #### customized packages + alsa-ucm-conf = prev.callPackage ./alsa-ucm-conf { pkgs = prev; }; fluffychat-moby = prev.callPackage ./fluffychat-moby { pkgs = prev; }; gpodder-configured = prev.callPackage ./gpodder-configured { pkgs = prev; }; # nixos-unstable pleroma is too far out-of-date for our db