]> git.alsa-project.org Git - alsa-ucm-conf.git/commitdiff
HDA-analog: Add output when only 'Master Playback' control exists
authorJaroslav Kysela <perex@perex.cz>
Mon, 12 Jan 2026 12:57:32 +0000 (13:57 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 12 Jan 2026 13:59:25 +0000 (14:59 +0100)
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 <perex@perex.cz>
ucm2/HDA/HiFi-analog.conf
ucm2/Intel/sof-hda-dsp/HiFi-sof.conf

index 8bf3e2103bdab957721290a2cebf28c20cb70dd2..e7e4aff715eb4260d1ba1486c2d4966423583cd8 100644 (file)
@@ -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 {
index b621d372f948a0a4a31e86142b6a930d581fee27..748132b2140102ae08878e22040d0592935d4eae 100644 (file)
@@ -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"