Commit graph

14 commits

Author SHA1 Message Date
Jaroslav Kysela
32addac948 ucm: substitute the merged tree completely
We need to define the common shared configuration like for multiple
HDMI devices or so. Substitute the whole merged configuration tree
including identifiers.

Fixes: https://github.com/alsa-project/alsa-lib/issues/67
Fixes: dcef48f13d
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-07-06 16:34:35 +02:00
Jaroslav Kysela
7c9f0fa436 ucm: implement AlwaysTrue Condition.Type
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-24 19:27:05 +02:00
Jaroslav Kysela
b66d69b72b ucm: fix the wrong uc_mgr_open_ctl() call in if_eval_control_exists()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-08 09:03:56 +02:00
Jaroslav Kysela
eee879d381 ucm: implement CardIdByName substitution
The syntax is ${CardIdByName:CARDNAME[#INDEX]}.

The CARDNAME is the ALSA's soundcard name (short form).
The INDEX is the instance (0 = first, 1 = second etc.).

Example: ${CardIdByName:HDA Intel PCH}
(which is identical to ${CardIdByName:HDA Intel PCH#0})

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-03 17:17:11 +02:00
Jaroslav Kysela
a53a104f79 ucm: String condition - implement Empty
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-05-26 16:11:34 +02:00
Jaroslav Kysela
3edfebc522 ucm: configuration - implement in-place Include
An example:

	Include {
		File "Inc.conf"
		Before.SectionDevice "Mic"
	}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-05-25 19:20:53 +02:00
Jaroslav Kysela
76c098bf6e ucm: merge the array items from the condition blocks
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-05-09 21:51:55 +02:00
Jaroslav Kysela
15970ebf7f ucm: add support for ControlEnum in ControlExists condition
Condition {
  Type ControlExists
  Control "name='Capture Input'"
  ControlEnum "Headphone Mic"
}

The result is true if the control exists, it is the enumerated
type and has the item with the ControlEnum text (name).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-29 09:34:09 +01:00
Jaroslav Kysela
6eb4f8a724 ucm: conditions - fix the wrong string/substring match
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-28 19:54:52 +01:00
Jaroslav Kysela
a0b00a954e ucm: add possibility to keep order of childs for If blocks
Because of the nature of the structured parser, it is not guaranteed
that the order of the parsed tree is equal to the lines in the source.

Add possibility to insert the If results before or after the selected
identifier like:

SectionDevice."Speaker" {
  ...
}

If.1 {
	Condition { ... }
	Before.SectionDevice "Speaker"
	True { ... }
}
If.2 {
	Condition { ... }
	After.SectionDevice "Speaker"
	True { ... }
}

If the "After" or "Before" identifiers are not found, the result is added
after the last entry in the block.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 17:21:20 +01:00
Jaroslav Kysela
1b14643384 ucm: add If.Condition.RegexMatch
If.1 {
	Condition {
		Type RegexMatch
		String "something to match"
		Regex ".*(thing)"
	}
	...
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
7ccaa08693 ucm: evaluate nested If blocks also in True/False blocks
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
b7d74c6977 ucm: add If.Condition.String to match strings and substrings
Case insensitive string match:

If.1 {
	Condition {
		Type String
		String1 "aa"
		String2 "bb"
	}
	True {
		...
	}
}

Substring is present (case sensitive):

If.1 {
	Condition {
		Type String
		Haystack "White Horse"
		Needle "Horse"
	}
	True {
		...
	}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
8a36e38dc4 ucm: add If condition block
The syntax is simple:

If./any-if-identificator/ {
  Condition {
    Type /type_here/
    /optional defines/
  }
  True {
    /block used when condition is evaluated as true/
  }
  False {
    /block used when condition is evaluated as false/
  }
}

The Type "ControlExists" is implemented:

Condition {
  Type ControlExists
  Device "hw:${CardId}"
  Control "iface=CARD,name='Headphone Jack'"
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:37 +01:00