#
# This is the toplevel file included from the alsa-lib.
#
# It allows to add extra lookups for the old kernels or so.
#
# You may specify the directory (relative to the toplevel) and
# the master configuration file which defines the verbs.
#

#
# Syntax version is reset for the master configuration file.
#

Syntax 4

Define.V1 ""		# non-empty string to enable ucm v1 paths
Define.V2ConfD yes	# empty string to disable
Define.V2Module ""	# non-empty string to enable module name lookups (obsolete)
Define.V2Name ""	# non-empty string to enable driver & card name lookups (obsolete)

Include.libgen.File "/lib/generic.conf"  # private alsa-lib configuration

If.driver {
	Condition {
		Type String
		Empty "${CardNumber}"
	}
	True {
		#
		# The probed path for no-hw-card:
		#
		#   ucm2/conf.virt.d/${OpenName}.conf
		#   ucm2/${OpenName}/${OpenName}.conf
		#
		UseCasePath {
			virt {
				Directory "conf.virt.d"
				File "${OpenName}.conf"
			}
			legacy {
				Directory "${OpenName}"
				File "${OpenName}.conf"
			}
		}
	}
	False {

		#
		# The probed path when hw-card is found:
		#
		#   ucm2/conf.d/[${CardDriver}|${KernelDriver}]/${CardLongName}.conf
		#   ucm2/conf.d/[${CardDriver}|${KernelDriver}]/[${CardDriver}|${KernelDriver}].conf
		#   ucm2/${KernelModule}/${KernelModule}.conf (obsolete)
		#   ucm2/${CardDriver}/${CardLongName}.conf (obsolete)
		#   ucm2/${CardDriver}/${CardDriver}.conf (obsolete)
		#

		If.V2ConfD {
			Condition {
				Type String
				Empty "${var:V2ConfD}"
			}
			False {
				Define.Driver "${CardDriver}"
				If.nodrv {
					Condition {
						Type String
						Empty "${var:Driver}"
					}
					True.Define {
						KernelDriverPath "class/sound/card${CardNumber}/device/driver"
						Driver "${sys:$KernelDriverPath}"
					}
				}
				UseCasePath.confd1 {
					Directory "conf.d/${var:Driver}"
					File "${CardLongName}.conf"
				}
				UseCasePath.confd2 {
					Directory "conf.d/${var:Driver}"
					File "${var:Driver}.conf"
				}
			}
		}
		If.V2Module {
			Condition {
				Type String
				Empty "${var:V2Module}"
			}
			False {
				Define.KernelModulePath "class/sound/card${CardNumber}/device/driver/module"
				Define.KernelModule "$${sys:$KernelModulePath}"
				UseCasePath.module {
					Directory "module"
					File "${var:KernelModule}.conf"
				}
			}
		}
		If.V2Name {
			Condition {
				Type String
				Empty "${var:V2Name}"
			}
			False.UseCasePath {
				longname {
					Directory "${CardDriver}"
					File "${CardLongName}.conf"
				}
				driver {
					Directory "${CardDriver}"
					File "${CardDriver}.conf"
				}
			}
		}
	}
}

If.V1 {
	Condition {
		Type String
		Empty "${var:V1}"
	}
	False.If.v1_driver {
		Condition {
			Type String
			Empty "${CardNumber}"
		}
		True {
			#
			# The probed path for no-hw-card:
			#
			#   ucm/${OpenName}/${OpenName}.conf
			#
			UseCasePath.v1_legacy {
				Version 1
				Directory "${OpenName}"
				File "${OpenName}.conf"
			}
		}
		False {
			#
			# The ucm v1 probed path when hw-card is found:
			#
			#   ucm/${CardLongName}/${CardLongName}.conf
			#   ucm/${CardName}/${CardName}.conf or \
			#			ucm/${OpenName}/${OpenName}.conf
			#
			UseCasePath.v1_longname {
				Version 1
				Directory "${CardLongName}"
				File "${CardLongName}.conf"
			}
			If.v1_hw {
				Condition {
					Type String
					Haystack "${OpenName}"
					Needle "hw:"
				}
				True.UseCasePath.v1_cardnamme {
					Version 1
					Directory "${CardName}"
					File "${CardName}.conf"
				}
				False.UseCasePath.v1_openname {
					Version 1
					Directory "${OpenName}"
					File "${OpenName}.conf"
				}
			}
		}
	}
}
