From 34c79da9ae38e7f68f9377ad26b573916337a53f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 12 Jan 2026 13:57:32 +0100 Subject: [PATCH] HDA-analog: Add output when only 'Master Playback' control exists There is a case when only one output is present (e.g. internal speakers or hp output). In this case, the driver offers only master volume controls. Add also more related cleanups for the line out and SOF HDA configs. Link: https://github.com/alsa-project/alsa-ucm-conf/issues/685 Fixes: c8b5541 ("ucm2: HDA: Headphone output may be optional") Signed-off-by: Jaroslav Kysela --- ucm2/HDA/HiFi-analog.conf | 70 ++++++++++++++++++++++------ ucm2/Intel/sof-hda-dsp/HiFi-sof.conf | 8 ++-- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/ucm2/HDA/HiFi-analog.conf b/ucm2/HDA/HiFi-analog.conf index 8bf3e21..e7e4aff 100644 --- a/ucm2/HDA/HiFi-analog.conf +++ b/ucm2/HDA/HiFi-analog.conf @@ -1,6 +1,7 @@ # Generic HDA devices for analog I/O Define.LineDevice "" +Define.spkvol "Speaker" Define.hpvol "Headphone" Define.hpjack "Headphone Jack" Define.loctl "Line" @@ -21,10 +22,21 @@ If.hpjack { } } +If.nolineout { + Condition { + Type ControlExists + Control "name='Line Playback Switch'" + } + False.Define { + loctl "" + lovol "" + } +} + If.lineout { Condition { Type ControlExists - Control "name='Line Out Playback Volume'" + Control "name='Line Out Playback Switch'" } True.Define { loctl "Line Out" @@ -61,6 +73,28 @@ If.hplo { } } +If.spkvol { + Condition { + Type ControlExists + Control "name='Speaker Playback Switch'" + } + False.Define.spkvol "" +} + +If.outnone { + Condition { + Type String + Empty "${var:hpvol}${var:spkvol}${var:lovol}" + } + True.If.master { + Condition { + Type ControlExists + Control "name='Master Playback Switch'" + } + True.Define.hpvol "Master" + } +} + If.hp { Condition { Type String @@ -88,20 +122,28 @@ If.hp { PlaybackPriority 200 PlaybackPCM "hw:${CardId}" PlaybackMixerElem "${var:hpvol}" - PlaybackMasterElem "Master" PlaybackVolume "${var:hpvol} Playback Volume" - PlaybackSwitch "Headphone Playback Switch" + PlaybackSwitch "${var:hpvol} Playback Switch" JackControl "${var:hpjack}" } + + If.master { + Condition { + Type String + String1 "${var:hpvol}" + String2 "Master" + } + False.Value.PlaybackMasterElem "Master" + } } } If.spk { Condition { - Type ControlExists - Control "name='Speaker Playback Switch'" + Type String + Empty "${var:spkvol}" } - True.SectionDevice."Speaker" { + False.SectionDevice."Speaker" { Comment "Speaker" If.seq { @@ -122,11 +164,11 @@ If.spk { } False { EnableSequence [ - cset "name='Speaker Playback Switch' on" + cset "name='${var:spkvol} Playback Switch' on" ] DisableSequence [ - cset "name='Speaker Playback Switch' off" + cset "name='${var:spkvol} Playback Switch' off" ] } } @@ -134,10 +176,10 @@ If.spk { Value { PlaybackPriority 100 PlaybackPCM "hw:${CardId}" - PlaybackMixerElem "Speaker" + PlaybackMixerElem "${var:spkvol}" PlaybackMasterElem "Master" - PlaybackVolume "Speaker Playback Volume" - PlaybackSwitch "Speaker Playback Switch" + PlaybackVolume "${var:spkvol} Playback Volume" + PlaybackSwitch "${var:spkvol} Playback Switch" } } } @@ -152,10 +194,10 @@ If.cap-sw { If.line { Condition { - Type ControlExists - Control "name='${var:loctl} Playback Switch'" + Type String + Empty "${var:loctl}" } - True.SectionDevice."Line${var:LineDevice}" { + False.SectionDevice."Line${var:LineDevice}" { Comment "Line Output" If.conflict { diff --git a/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf b/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf index b621d37..748132b 100644 --- a/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf +++ b/ucm2/Intel/sof-hda-dsp/HiFi-sof.conf @@ -44,8 +44,8 @@ DefineMacro.SofAnalogPlaybackControl { # Merge this to Headpones subtree in HDA/HiFi-analog.conf If.hp { Condition { - Type ControlExists - Control "name='Headphone Playback Switch'" + Type String + Empty "${var:hpvol}" } True.SectionDevice."Headphones" { Macro.headphone.SofAnalogPlaybackControl "endpoint=Headphone drcswitch=off" @@ -55,8 +55,8 @@ If.hp { # Merge this to Speaker subtree in HDA/HiFi-analog.conf If.spk { Condition { - Type ControlExists - Control "name='Speaker Playback Switch'" + Type String + Empty "${var:spkvol}" } True.SectionDevice."Speaker" { Macro.speaker.SofAnalogPlaybackControl "endpoint=Speaker drcswitch=on" -- 2.47.3