diff mbox series

[alsa-ucm-conf,v3,2/2] sof-soundwire: Add basic support for basic cs35l56 configurations

Message ID 20231206164612.1362203-2-ckeepax@opensource.cirrus.com (mailing list archive)
State Superseded
Headers show
Series [alsa-ucm-conf,v3,1/2] sof-soundwire: Add basic support for cs42l43 | expand

Commit Message

Charles Keepax Dec. 6, 2023, 4:46 p.m. UTC
cs35l56 is a boosted speaker amp, add UCM support for configurations
with up to 8 amps.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---

Changes since v2:
 - Rebased on top of conversion of the Realtek amps.
 - Add a macro for each amp to simplify things a bit.

Thanks,
Charles

 ucm2/sof-soundwire/cs35l56.conf | 41 +++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 ucm2/sof-soundwire/cs35l56.conf

Comments

Jaroslav Kysela Dec. 6, 2023, 5:46 p.m. UTC | #1
On 06. 12. 23 17:46, Charles Keepax wrote:
> cs35l56 is a boosted speaker amp, add UCM support for configurations
> with up to 8 amps.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> ---
> 
> Changes since v2:
>   - Rebased on top of conversion of the Realtek amps.
>   - Add a macro for each amp to simplify things a bit.

Thanks. This patch was inspiration for me. Could you check modifications in 
https://github.com/alsa-project/alsa-ucm-conf/pull/370 ? We can use regex to 
create condition against SpeakerAmps variable, so the configuration may look like:

...
	Condition {
		Type RegexMatch
		Regex "${var:__ForAmps}"
		String "${var:SpeakerAmps}"
	}
...
	Macro.num1.cs42l43spk { ForAmps "[12468]" Amp 1 }
	Macro.num2.cs42l43spk { ForAmps "[2468]" Amp 2 }
	Macro.num3.cs42l43spk { ForAmps "[468]" Amp 3 }
	Macro.num4.cs42l43spk { ForAmps "[468]" Amp 4 }
	Macro.num5.cs42l43spk { ForAmps "[68]" Amp 5 }
	Macro.num6.cs42l43spk { ForAmps "[68]" Amp 6 }
	Macro.num7.cs42l43spk { ForAmps "8" Amp 7 }
	Macro.num8.cs42l43spk { ForAmps "8" Amp 8 }
...

I assume that only even count for amplifiers is valid (with mono exception).

						Jaroslav
Charles Keepax Dec. 7, 2023, 9:57 a.m. UTC | #2
On Wed, Dec 06, 2023 at 06:46:18PM +0100, Jaroslav Kysela wrote:
> On 06. 12. 23 17:46, Charles Keepax wrote:
> >cs35l56 is a boosted speaker amp, add UCM support for configurations
> >with up to 8 amps.
> >
> >Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> >---
> >
> >Changes since v2:
> >  - Rebased on top of conversion of the Realtek amps.
> >  - Add a macro for each amp to simplify things a bit.
> 
> Thanks. This patch was inspiration for me. Could you check
> modifications in
> https://github.com/alsa-project/alsa-ucm-conf/pull/370 ? We can use

Some comments on the Github, would you rather I submitted my
patches through a github pull request as well? I am happy using
either that or email to submit the patches, so if you have a
preference I will do that.

Thanks,
Charles
diff mbox series

Patch

diff --git a/ucm2/sof-soundwire/cs35l56.conf b/ucm2/sof-soundwire/cs35l56.conf
new file mode 100644
index 0000000..7eca3fd
--- /dev/null
+++ b/ucm2/sof-soundwire/cs35l56.conf
@@ -0,0 +1,41 @@ 
+# Use case Configuration for sof-soundwire card
+
+#
+# Arguments:
+#   Amp - Amp number 1-8
+#
+
+DefineMacro.cs42l43spk {
+	If.amppresent {
+		Condition {
+			Type ControlExists
+			Control "name='AMP${var:__Amp} Speaker Switch'"
+		}
+		True {
+			EnableSequence [
+				cset "name='AMP${var:__Amp} Speaker Switch' 1"
+			]
+			DisableSequence [
+				cset "name='AMP${var:__Amp} Speaker Switch' 0"
+			]
+		}
+	}
+}
+
+SectionDevice."Speaker" {
+	Comment "Speaker"
+
+	Macro.num1.cs42l43spk { Amp 1 }
+	Macro.num2.cs42l43spk { Amp 2 }
+	Macro.num3.cs42l43spk { Amp 3 }
+	Macro.num4.cs42l43spk { Amp 4 }
+	Macro.num5.cs42l43spk { Amp 5 }
+	Macro.num6.cs42l43spk { Amp 6 }
+	Macro.num7.cs42l43spk { Amp 7 }
+	Macro.num8.cs42l43spk { Amp 8 }
+
+	Value {
+		PlaybackPriority 100
+		PlaybackPCM "hw:${CardId},2"
+	}
+}