alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Hans de Goede <hdegoede@redhat.com>,
	alsa-devel@alsa-project.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Bard Liao <bard.liao@intel.com>
Subject: [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control
Date: Mon,  8 Mar 2021 23:05:54 +0100	[thread overview]
Message-ID: <20210308220554.76111-8-hdegoede@redhat.com> (raw)
In-Reply-To: <20210308220554.76111-1-hdegoede@redhat.com>

Newer kernels add "aif:1" or "aif:2" to the components string to let
us know which AIF is being used.

Use this to specify the correct Playback/CaptureMasterElem for HW
volume-control, based on which AIF is being used.

On older kernels, where there is no "aif:%d" string in the components
string, no Playback/CaptureMasterElem is specified.

In DigitalMics.conf the master mixer is used as regular CaptureMixerElem
instead of as CaptureMasterElem since the DMICs don't have any analog
volume control.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 ucm2/bytcr-rt5640/HiFi.conf             | 21 +++++++++++++++++++++
 ucm2/codecs/rt5640/DigitalMics.conf     | 16 ++++++++++++++++
 ucm2/codecs/rt5640/HeadPhones.conf      | 12 ++++++++++++
 ucm2/codecs/rt5640/HeadsetMic.conf      | 12 ++++++++++++
 ucm2/codecs/rt5640/IN1-InternalMic.conf | 12 ++++++++++++
 ucm2/codecs/rt5640/IN3-InternalMic.conf | 12 ++++++++++++
 ucm2/codecs/rt5640/MonoSpeaker.conf     | 12 ++++++++++++
 ucm2/codecs/rt5640/Speaker.conf         | 12 ++++++++++++
 8 files changed, 109 insertions(+)

diff --git a/ucm2/bytcr-rt5640/HiFi.conf b/ucm2/bytcr-rt5640/HiFi.conf
index a5c05ba..7d504d1 100644
--- a/ucm2/bytcr-rt5640/HiFi.conf
+++ b/ucm2/bytcr-rt5640/HiFi.conf
@@ -1,5 +1,26 @@
 # Use case Configuration for bytcr-rt5640
 
+Define.HaveAif1 ""
+Define.HaveAif2 ""
+
+If.DefineAif1 {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "aif:1"
+	}
+	True.Define.HaveAif1 "yes"
+}
+
+If.DefineAif2 {
+	Condition {
+		Type String
+		Haystack "${CardComponents}"
+		Needle "aif:2"
+	}
+	True.Define.HaveAif2 "yes"
+}
+
 SectionVerb {
 	Include.e.File "/codecs/rt5640/EnableSeq.conf"
 
diff --git a/ucm2/codecs/rt5640/DigitalMics.conf b/ucm2/codecs/rt5640/DigitalMics.conf
index 157c544..032d954 100644
--- a/ucm2/codecs/rt5640/DigitalMics.conf
+++ b/ucm2/codecs/rt5640/DigitalMics.conf
@@ -26,5 +26,21 @@ SectionDevice."Mic" {
 	Value {
 		CapturePriority 100
 		CapturePCM "hw:${CardId}"
+		If.DmicAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMixerElem "ADC"
+				CaptureVolume "ADC Capture Volume"
+				CaptureSwitch "ADC Capture Switch"
+			}
+		}
+		If.DmicAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMixerElem "Mono ADC"
+				CaptureVolume "Mono ADC Capture Volume"
+				CaptureSwitch "Mono ADC Capture Switch"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/HeadPhones.conf b/ucm2/codecs/rt5640/HeadPhones.conf
index 5535111..4fbe95d 100644
--- a/ucm2/codecs/rt5640/HeadPhones.conf
+++ b/ucm2/codecs/rt5640/HeadPhones.conf
@@ -37,5 +37,17 @@ SectionDevice."Headphones" {
 		JackControl "Headphone Jack"
 		PlaybackMixerElem "HP"
 		PlaybackVolume "HP Playback Volume"
+		If.HpAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				PlaybackMasterElem "DAC1"
+			}
+		}
+		If.HpAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				PlaybackMasterElem "DAC2"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/HeadsetMic.conf b/ucm2/codecs/rt5640/HeadsetMic.conf
index 8479672..b49dad4 100644
--- a/ucm2/codecs/rt5640/HeadsetMic.conf
+++ b/ucm2/codecs/rt5640/HeadsetMic.conf
@@ -43,5 +43,17 @@ SectionDevice."Headset" {
 		JackControl "Headset Mic Jack"
 		CaptureMixerElem "IN2 Boost"
 		CaptureVolume "IN2 Boost"
+		If.HSmicAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMasterElem "ADC"
+			}
+		}
+		If.HSmicAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMasterElem "Mono ADC"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/IN1-InternalMic.conf b/ucm2/codecs/rt5640/IN1-InternalMic.conf
index a317388..d670484 100644
--- a/ucm2/codecs/rt5640/IN1-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN1-InternalMic.conf
@@ -34,5 +34,17 @@ SectionDevice."Mic" {
 		CapturePCM "hw:${CardId}"
 		CaptureMixerElem "IN1 Boost"
 		CaptureVolume "IN1 Boost"
+		If.In1Aif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMasterElem "ADC"
+			}
+		}
+		If.In1Aif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMasterElem "Mono ADC"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/IN3-InternalMic.conf b/ucm2/codecs/rt5640/IN3-InternalMic.conf
index ef4eaba..345db1e 100644
--- a/ucm2/codecs/rt5640/IN3-InternalMic.conf
+++ b/ucm2/codecs/rt5640/IN3-InternalMic.conf
@@ -34,5 +34,17 @@ SectionDevice."Mic" {
 		CapturePCM "hw:${CardId}"
 		CaptureMixerElem "IN3 Boost"
 		CaptureVolume "IN3 Boost"
+		If.In3Aif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				CaptureMasterElem "ADC"
+			}
+		}
+		If.In3Aif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				CaptureMasterElem "Mono ADC"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/MonoSpeaker.conf b/ucm2/codecs/rt5640/MonoSpeaker.conf
index 3cbeafd..addaddd 100644
--- a/ucm2/codecs/rt5640/MonoSpeaker.conf
+++ b/ucm2/codecs/rt5640/MonoSpeaker.conf
@@ -31,5 +31,17 @@ SectionDevice."Speaker" {
 		PlaybackPCM "hw:${CardId}"
 		PlaybackMixerElem "Speaker"
 		PlaybackVolume "Speaker Playback Volume"
+		If.MonoSpkAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				PlaybackMasterElem "DAC1"
+			}
+		}
+		If.MonoSpkAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				PlaybackMasterElem "DAC2"
+			}
+		}
 	}
 }
diff --git a/ucm2/codecs/rt5640/Speaker.conf b/ucm2/codecs/rt5640/Speaker.conf
index 0924f9c..e7ff673 100644
--- a/ucm2/codecs/rt5640/Speaker.conf
+++ b/ucm2/codecs/rt5640/Speaker.conf
@@ -31,5 +31,17 @@ SectionDevice."Speaker" {
 		PlaybackPCM "hw:${CardId}"
 		PlaybackMixerElem "Speaker"
 		PlaybackVolume "Speaker Playback Volume"
+		If.SpkAif1 {
+			Condition { Type String Empty "${var:HaveAif1}" }
+			False {
+				PlaybackMasterElem "DAC1"
+			}
+		}
+		If.SpkAif2 {
+			Condition { Type String Empty "${var:HaveAif2}" }
+			False {
+				PlaybackMasterElem "DAC2"
+			}
+		}
 	}
 }
-- 
2.30.1


  parent reply	other threads:[~2021-03-08 22:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 22:05 [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 1/7] codecs/rt5640: Cleanup: unify Stereo / Mono ADC handling Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 2/7] codecs/rt5640: Cleanup: Initially disable all inputs and outputs Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 3/7] codecs/rt5640: Cleanup: Move 'SPK MIX' setup to main EnableSequene Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 4/7] codecs/rt5640: Drop bogus 'DIG MIXL DAC L2 Switch' setting Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 5/7] codecs/rt5640: Unify capture volume for AIF1 and AIF2 recording paths Hans de Goede
2021-03-08 22:05 ` [PATCH alsa-ucm-conf v2 6/7] codecs/rt5640: Add hardware volume-control support Hans de Goede
2021-03-08 22:05 ` Hans de Goede [this message]
2021-03-13 12:10   ` [PATCH alsa-ucm-conf v2 7/7] codecs/rt5640: Specify Playback/CaptureMasterElem for HW volume-control Hans de Goede
2021-03-13 16:05     ` Jaroslav Kysela
2021-03-10 10:24 ` [PATCH alsa-ucm-conf v2 0/7] codecs/rt5640: Cleanup + HW volume control support Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210308220554.76111-8-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bard.liao@intel.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).