From 01c2b4e708ef3bfb1b185b785f11d0b55702e990 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 10 Mar 2025 17:11:49 +0100 Subject: [PATCH] USB-Audio: Improve support for Focusrite 4th Gen devices There are 4 capture channels (additional ones for mixer monitor). Closes: https://github.com/alsa-project/alsa-ucm-conf/issues/515 Closes: https://github.com/alsa-project/alsa-ucm-conf/pull/516 Signed-off-by: Jaroslav Kysela --- .../USB-Audio/Focusrite/Scarlett-2i-HiFi.conf | 4 +- .../Focusrite/Scarlett-2i-gen4-HiFi.conf | 124 ++++++++++++++++++ ucm2/USB-Audio/Focusrite/Scarlett-2i.conf | 40 +++++- 3 files changed, 160 insertions(+), 8 deletions(-) create mode 100644 ucm2/USB-Audio/Focusrite/Scarlett-2i-gen4-HiFi.conf diff --git a/ucm2/USB-Audio/Focusrite/Scarlett-2i-HiFi.conf b/ucm2/USB-Audio/Focusrite/Scarlett-2i-HiFi.conf index 0484dc7..0fdd55c 100644 --- a/ucm2/USB-Audio/Focusrite/Scarlett-2i-HiFi.conf +++ b/ucm2/USB-Audio/Focusrite/Scarlett-2i-HiFi.conf @@ -14,7 +14,7 @@ Macro [ } ] -If.2i4 { +If.pch4 { Condition { Type String String1 "${var:PlaybackChannels}" @@ -65,7 +65,7 @@ SectionDevice."Line1" { } } -If.2i4 { +If.line2 { Condition { Type String String1 "${var:PlaybackChannels}" diff --git a/ucm2/USB-Audio/Focusrite/Scarlett-2i-gen4-HiFi.conf b/ucm2/USB-Audio/Focusrite/Scarlett-2i-gen4-HiFi.conf new file mode 100644 index 0000000..087239b --- /dev/null +++ b/ucm2/USB-Audio/Focusrite/Scarlett-2i-gen4-HiFi.conf @@ -0,0 +1,124 @@ +Include.pcm_split.File "/common/pcm/split.conf" + +Macro [ + { + SplitPCM { + Name "scarlett2i_mono_in" + Direction Capture + Format S32_LE + Channels 1 + HWChannels 4 + HWChannelPos0 MONO + HWChannelPos1 MONO + } + } + { + SplitPCM { + Name "scarlett2i_stereo_in" + Direction Capture + Format S32_LE + Channels 2 + HWChannels 4 + HWChannelPos0 MONO + HWChannelPos1 MONO + HWChannelPos2 FL + HWChannelPos3 FR + } + } +] + +SectionDevice."Line1" { + Comment "${var:Playback1Name}" + + Value { + PlaybackPriority 200 + PlaybackPCM "hw:${CardId}" + } +} + +SectionDevice."Mic1" { + Comment "${var:Capture1Name}" + + Value { + CapturePriority 500 + } + Macro.pcm_split.SplitPCMDevice { + Name "scarlett2i_mono_in" + Direction Capture + HWChannels 4 + Channels 1 + Channel0 0 + ChannelPos0 MONO + } +} + +SectionDevice."Mic2" { + Comment "${var:Capture2Name}" + + Value { + CapturePriority 400 + } + Macro.pcm_split.SplitPCMDevice { + Name "scarlett2i_mono_in" + Direction Capture + HWChannels 4 + Channels 1 + Channel0 1 + ChannelPos0 MONO + } +} + +SectionDevice."Line2" { + Comment "Monitor Input 3+4 (stereo)" + + ConflictingDevice [ + "Line3" + "Line4" + ] + + Value { + CapturePriority 300 + } + Macro.pcm_split.SplitPCMDevice { + Name "scarlett2i_stereo_in" + Direction Capture + HWChannels 4 + Channels 2 + Channel0 2 + Channel1 3 + ChannelPos0 FL + ChannelPos1 FR + } +} + +SectionDevice."Line3" { + Comment "Monitor Input 3" + + Value { + CapturePriority 200 + } + Macro.pcm_split.SplitPCMDevice { + Name "scarlett2i_mono_in" + Direction Capture + HWChannels 4 + Channels 1 + Channel0 2 + ChannelPos0 MONO + } +} + +SectionDevice."Line4" { + Comment "Monitor Input 4" + + Value { + CapturePriority 100 + } + Macro.pcm_split.SplitPCMDevice { + Name "scarlett2i_mono_in" + Direction Capture + HWChannels 4 + Channels 1 + Channel0 3 + ChannelPos0 MONO + } +} diff --git a/ucm2/USB-Audio/Focusrite/Scarlett-2i.conf b/ucm2/USB-Audio/Focusrite/Scarlett-2i.conf index fa03229..a27c7f9 100644 --- a/ucm2/USB-Audio/Focusrite/Scarlett-2i.conf +++ b/ucm2/USB-Audio/Focusrite/Scarlett-2i.conf @@ -1,13 +1,14 @@ Define { PlaybackChannels 2 - DirectPlaybackChannels 2 - DirectCaptureChannels 2 + CaptureChannels 2 Model "2i2" Playback1Name "Headphones / Line 1-2" Playback2Name "Line 3-4" Capture1Name "Input 1 Mic/Inst/Line" Capture2Name "Input 2 Mic/Inst/Line" + CaptureMonitor "" Generation "1st" + Profile "Scarlett-2i-HiFi" } If.solo { @@ -55,20 +56,47 @@ If.gen3 { True.Define.Generation "3rd" } -If.gen4 { +If.gen4-solo { Condition { Type RegexMatch String "${CardComponents}" - Regex "USB1235:821[89]" + Regex "USB1235:8218" + } + True.Define { + Generation "4th" + Capture1Name "Input 1 Inst/Line" + Capture2Name "Input 2 Mic" + CaptureChannels 4 + Profile "Scarlett-2i-gen4-HiFi" + } +} + +If.gen4-2i2 { + Condition { + Type RegexMatch + String "${CardComponents}" + Regex "USB1235:8219" + } + True.Define { + Generation "4th" + CaptureChannels 4 + Profile "Scarlett-2i-gen4-HiFi" } - True.Define.Generation "4th" } Comment "Focusrite Scarlett ${var:Model} ${var:Generation} Gen" SectionUseCase."HiFi" { Comment "Default" - File "/USB-Audio/Focusrite/Scarlett-2i-HiFi.conf" + File "/USB-Audio/Focusrite/${var:Profile}.conf" +} + +If.dhw { + Condition { Type AlwaysTrue } + True.Define { + DirectPlaybackChannels "${var:PlaybackChannels}" + DirectCaptureChannels "${var:CaptureChannels}" + } } Include.dhw.File "/common/direct.conf" -- 2.47.1