From 8944ee3ebcafabe3018772529c60d814ea6123a4 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 4 Jun 2021 12:02:53 +0200 Subject: [PATCH] hda: improve the microphone device allocation This change use the local variables for the UCM microphone device names. Also, handle the no-dmic case for sof-hda-dsp hardware. Signed-off-by: Jaroslav Kysela --- ucm2/HDA-Intel/HDA-Intel.conf | 6 ++- ucm2/HDA-Intel/HiFi-analog.conf | 4 +- ucm2/HDA-Intel/HiFi.conf | 5 +-- ucm2/sof-hda-dsp/HiFi.conf | 69 +++++++++++++++++-------------- ucm2/sof-hda-dsp/sof-hda-dsp.conf | 33 +++++++++++---- 5 files changed, 71 insertions(+), 46 deletions(-) diff --git a/ucm2/HDA-Intel/HDA-Intel.conf b/ucm2/HDA-Intel/HDA-Intel.conf index 8a8e0e7..0d10fd4 100644 --- a/ucm2/HDA-Intel/HDA-Intel.conf +++ b/ucm2/HDA-Intel/HDA-Intel.conf @@ -3,13 +3,17 @@ Syntax 4 Define.Use "" # a non-empty string to use UCM configuration for HDA devices Define.AcpCardId "$${find-card:field=name,return=id,regex='^acp$'}" +Define.DeviceMic "Mic" If.acp { Condition { Type String Empty "${var:AcpCardId}" } - False.Define.Use y + False { + Define.Use y + Define.DeviceMic "Mic2" + } } If.use { diff --git a/ucm2/HDA-Intel/HiFi-analog.conf b/ucm2/HDA-Intel/HiFi-analog.conf index 1de9f9d..dd0da02 100644 --- a/ucm2/HDA-Intel/HiFi-analog.conf +++ b/ucm2/HDA-Intel/HiFi-analog.conf @@ -87,7 +87,7 @@ If.monomic { ControlEnum "Headphone Mic" } True { - SectionDevice."Mic2" { + SectionDevice."${var:DeviceMic}" { Comment "Headphones Stereo Microphone" ConflictingDevice [ @@ -122,7 +122,7 @@ If.monomic { } } False { - SectionDevice."Mic2" { + SectionDevice."${var:DeviceMic}" { Comment "Headphones Stereo Microphone" Value { diff --git a/ucm2/HDA-Intel/HiFi.conf b/ucm2/HDA-Intel/HiFi.conf index f09ce1c..9f31e07 100644 --- a/ucm2/HDA-Intel/HiFi.conf +++ b/ucm2/HDA-Intel/HiFi.conf @@ -16,11 +16,8 @@ If.analog { Type String Empty "${var:AcpCardId}" } - True { - RenameDevice."Mic1" "Mic" - } False.Include.acp { - Before.SectionDevice "Mic1" + Before.SectionDevice "${var:DeviceMic}" File "/HDA-Intel/HiFi-acp.conf" } } diff --git a/ucm2/sof-hda-dsp/HiFi.conf b/ucm2/sof-hda-dsp/HiFi.conf index 2c02c15..867769c 100644 --- a/ucm2/sof-hda-dsp/HiFi.conf +++ b/ucm2/sof-hda-dsp/HiFi.conf @@ -4,43 +4,48 @@ SectionVerb { Value.TQ "HiFi" } - +Include.hda-analog.File "/HDA-Intel/HiFi-analog.conf" -If.monomic.After.SectionDevice "Mic1" - -SectionDevice."Mic1" { - Comment "Digital Microphone" +If.dmic { + Condition { + Type String + Empty "${var:DeviceDmic}" + } + Before.SectionDevice "${var:DeviceMic}" + False.SectionDevice."${var:DeviceDmic}" { + Comment "Digital Microphone" - Value { - CapturePriority 100 - CapturePCM "hw:${CardId},6" - If.chn { - Condition { - Type RegexMatch - Regex "cfg-dmics:[34]" - String "${CardComponents}" - } - True { - CaptureChannels 4 - } - } - If.vol { - Condition { - Type ControlExists - Control "name='Dmic0 Capture Switch'" - } - True { - CaptureMixerElem "Dmic0" - CaptureVolume "Dmic0 Capture Volume" - CaptureSwitch "Dmic0 Capture Switch" + Value { + CapturePriority 100 + CapturePCM "hw:${CardId},6" + If.chn { + Condition { + Type RegexMatch + Regex "cfg-dmics:[34]" + String "${CardComponents}" + } + True { + CaptureChannels 4 + } } - False { - # v1.3 SOF firmware - CaptureMixerElem "PGA10.0 10 Master" - CaptureVolume "PGA10.0 10 Master Capture Volume" + If.vol { + Condition { + Type ControlExists + Control "name='Dmic0 Capture Switch'" + } + True { + CaptureMixerElem "Dmic0" + CaptureVolume "Dmic0 Capture Volume" + CaptureSwitch "Dmic0 Capture Switch" + } + False { + # v1.3 SOF firmware + CaptureMixerElem "PGA10.0 10 Master" + CaptureVolume "PGA10.0 10 Master Capture Volume" + } } } } } - +Include.hdmi.File "/sof-hda-dsp/Hdmi.conf" diff --git a/ucm2/sof-hda-dsp/sof-hda-dsp.conf b/ucm2/sof-hda-dsp/sof-hda-dsp.conf index ca3473a..4c222fa 100644 --- a/ucm2/sof-hda-dsp/sof-hda-dsp.conf +++ b/ucm2/sof-hda-dsp/sof-hda-dsp.conf @@ -1,4 +1,17 @@ -Syntax 3 +Syntax 4 + +Define.DeviceMic "Mic" +Define.DeviceDmic "" + +If.dmic { + Condition { + Type String + Haystack "${CardComponents}" + Needle "cfg-dmics:" + } + True.Define.DeviceDmic "Mic1" + True.Define.DeviceMic "Mic2" +} SectionUseCase."HiFi" { File "HiFi.conf" @@ -48,14 +61,20 @@ If.headphone { ] } -If.Dmic0 { +If.dmic { Condition { - Type ControlExists - Control "name='Dmic0 Capture Volume'" + Type String + Empty "${var:DeviceDmic}" + } + False.If.Dmic0 { + Condition { + Type ControlExists + Control "name='Dmic0 Capture Volume'" + } + True.BootSequence [ + cset "name='Dmic0 Capture Volume' 70%" + ] } - True.BootSequence [ - cset "name='Dmic0 Capture Volume' 70%" - ] } If.Capture { -- 2.47.1