Define {
	SpeakerMixer "PCM"
	SpeakerMindex "0"
	SpeakerJack "Speaker - Output Jack"
	SpeakerPCM "hw:${CardId}"

	HeadphonesName "Front Headphones"
	HeadphonesMixer "PCM"
	HeadphonesMindex "1"
	HeadphonesJack "Headphone - Output Jack"
	HeadphonesPCM "hw:${CardId},1"

	Mic1Name "Microphone"
	Mic1Mixer "Mic"
	Mic1Mindex "0"
	Mic1Jack "Mic - Input Jack"
	Mic1PCM "hw:${CardId},2"

	Mic2Name ""
	Mic2Mixer ""
	Mic2Mindex "0"
	Mic2Jack ""
	Mic2PCM ""

	Line1Name "Line Input"
	Line1Mixer "Line"
	Line1Mindex "0"
	Line1Jack "Line - Input Jack"
	Line1PCM "hw:${CardId},1"

	SpdifName "S/PDIF Output"
	SpdifPCM "hw:${CardId},3"
	SpdifMixer "PCM"
	SpdifMindex "2"
}

If.speaker_ctl {
	Condition {
		Type ControlExists
		Control "name='Speaker Playback Switch'"
	}
	True.Define.SpeakerMixer "Speaker"
}

If.front_hp_ctl {
	Condition {
		Type ControlExists
		Control "name='Front Headphone Playback Switch'"
	}
	True.Define {
		HeadphonesMixer "Front Headphone"
		HeadphonesMindex "0"
	}
}

If.spdif_ctl {
	Condition {
		Type ControlExists
		Control "name='IEC958 Playback Switch'"
	}
	True.Define {
		SpdifMixer "IEC958"
		SpdifMindex "0"
	}
}

If.spdif_nodev {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0db0:36e7)"
	}
	True.Define.SpdifName ""
}

If.spdif_dev2 {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0b05:(1996|1a5[23c])|0db0:1feb)"
	}
	True.Define.SpdifPCM "hw:${CardId},2"
}

If.gigabyte-aorus-ultra {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0414:a014)"
	}
	True.Define {
		Mic1Name "Front Microphone"
		Mic1PCM "hw:${CardId},0"
		SpdifName ""
		Line1Name ""
	}
}

If.asus-rog-usb {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0b05:1996)"
	}
	True.Define {
		Mic1Name "Front Microphone"
		Mic2Name "Microphone"
		Mic2Mixer "Analog In"
		Mic2Jack "Analog In - Input Jack"
		Mic2PCM "hw:${CardId}"
	}
}

If.asrock-taichi {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(26ce:0a0[68])"
	}
	True.Define {
		Line1Name ""
		Mic1Name "Rear Input"
		Mic1PCM "hw:${CardId},0"
		Mic2Name "Front Microphone"
		Mic2Mixer "Mic"
		Mic2Jack "Front Mic - Input Jack"
		Mic2PCM "hw:${CardId},1"
	}
}

If.wrx80-sage {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0b05:1984)"
	}
	True.Define {
		Mic2Name "Front Microphone"
		Mic2Mixer "Analog In"
		Mic2Jack "Analog In - Input Jack"
		Mic2PCM "hw:${CardId}"
	}
}

If.msi-meg-unify {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0db0:82c7)"
	}
	True.Define {
		HeadphonesName ""
		SpdifName ""
	}
}

If.asus-rog-strix {
	Condition {
		Type RegexMatch
		String "${CardComponents}"
		Regex "USB(0b05:1999)"
	}
	True.Define {
		Line1PCM "hw:${CardId},3"
		HeadphonesName ""
		SpdifName ""
	}
}

SectionVerb {
	EnableSequence [
		disdevall ""
	]

	Value.TQ "HiFi"
}

SectionDevice."Speaker" {
	Comment "Speakers"

	EnableSequence [
		cset "name='${var:SpeakerMixer} Playback Switch',index=${var:SpeakerMindex} on"
	]

	DisableSequence [
		cset "name='${var:SpeakerMixer} Playback Switch',index=${var:SpeakerMindex} off"
	]

	Value {
		PlaybackChannels 2
		PlaybackPriority 200
		PlaybackPCM "${var:SpeakerPCM}"
		JackControl "${var:SpeakerJack}"
		PlaybackMixerElem "${var:SpeakerMixer},${var:SpeakerMindex}"
	}

	Variant."HiFi 5+1".Value.PlaybackChannels 6
	Variant."HiFi 7+1".Value.PlaybackChannels 8
}

If.headphones {
	Condition {
		Type String
		Empty "${var:HeadphonesName}"
	}
	False.SectionDevice."Headphones" {
		Comment "${var:HeadphonesName}"

		EnableSequence [
			cset "name='${var:HeadphonesMixer} Playback Switch',index=${var:HeadphonesMindex} on"
		]

		DisableSequence [
			cset "name='${var:HeadphonesMixer} Playback Switch',index=${var:HeadphonesMindex} off"
		]

		Value {
			PlaybackPriority 300
			PlaybackPCM "${var:HeadphonesPCM}"
			JackControl "${var:HeadphonesJack}"
			PlaybackMixerElem "${var:HeadphonesMixer},${var:HeadphonesMindex}"
		}
	}
}

If.spdif {
	Condition {
		Type String
		Empty "${var:SpdifName}"
	}
	False.SectionDevice."SPDIF" {
		Comment "${var:SpdifName}"

		EnableSequence [
			cset "name='${var:SpdifMixer} Playback Switch',index=${var:SpdifMindex} on"
		]

		DisableSequence [
			cset "name='${var:SpdifMixer} Playback Switch',index=${var:SpdifMindex} off"
		]

		Value {
			PlaybackPriority 100
			PlaybackPCM "${var:SpdifPCM}"
			PlaybackMixerElem "${var:SpdifMixer},${var:SpdifMindex}"
		}
	}
}

If.line1 {
	Condition {
		Type String
		Empty "${var:Line1Name}"
	}
	False.SectionDevice."Line1" {
		Comment "${var:Line1Name}"

		EnableSequence [
			cset "name='${var:Line1Mixer} Capture Switch',index=${var:Line1Mindex} on"
		]

		DisableSequence [
			cset "name='${var:Line1Mixer} Capture Switch',index=${var:Line1Mindex} off"
		]

		Value {
			CapturePriority 100
			CapturePCM "${var:Line1PCM}"
			JackControl "${var:Line1Jack}"
			CaptureMixerElem "${var:Line1Mixer},${var:Line1Mindex}"
		}
	}
}

If.mic1 {
	Condition {
		Type String
		Empty "${var:Mic1Name}"
	}
	False.SectionDevice."Mic1" {
		Comment "${var:Mic1Name}"

		EnableSequence [
			cset "name='${var:Mic1Mixer} Capture Switch',index=${var:Mic1Mindex} on"
		]

		DisableSequence [
			cset "name='${var:Mic1Mixer} Capture Switch',index=${var:Mic1Mindex} off"
		]

		Value {
			CapturePriority 300
			CapturePCM "${var:Mic1PCM}"
			JackControl "${var:Mic1Jack}"
			CaptureMixerElem "${var:Mic1Mixer},${var:Mic1Mindex}"
		}
	}
}

If.mic2 {
	Condition {
		Type String
		Empty "${var:Mic2Name}"
	}
	False.SectionDevice."Mic2" {
		Comment "${var:Mic2Name}"

		EnableSequence [
			cset "name='${var:Mic2Mixer} Capture Switch',index=${var:Mic2Mindex} on"
		]

		DisableSequence [
			cset "name='${var:Mic2Mixer} Capture Switch',index=${var:Mic2Mindex} off"
		]

		Value {
			CapturePriority 400
			CapturePCM "${var:Mic2PCM}"
			JackControl "${var:Mic2Jack}"
			CaptureMixerElem "${var:Mic2Mixer},${var:Mic2Mindex}"
		}
	}
}
