SectionVerb {
	EnableSequence [
		disdevall ""
		# Disable all inputs / outputs
		#   (may be duplicated with disdevall)
		cset "name='Headphone Switch' off"
		cset "name='Headset Mic Switch' off"
		cset "name='Internal Mic Switch' off"
		cset "name='DAC Mono Mix Switch' off"
	]
}

If.amic {
	Condition {
		Type String
		Empty "${var:DeviceDmic}"
	}
	True.SectionDevice."Mic" {
		Comment "Analog Microphone"

		ConflictingDevice [
			"Headset"
		]

		EnableSequence [
			cset "name='Differential Mux' lin1-rin1"
			cset "name='Internal Mic Switch' on"
		]

		DisableSequence [
			cset "name='Internal Mic Switch' off"
		]

		Value {
			CapturePriority 100
			CapturePCM "hw:${CardId}"
			CaptureMixerElem "ADC PGA Gain"
			CaptureMasterElem "ADC"
		}
	}
}

If.dmic {
	Condition {
		Type String
		Empty "${var:DeviceDmic}"
	}
	False.SectionDevice."${var:DeviceDmic}" {
		Comment "Digital Microphone"

		Value {
			CapturePriority 100
			CapturePCM "hw:${CardId},1"
			If.chn {
				Condition {
					Type RegexMatch
					Regex "cfg-dmics:[34]"
					String "${CardComponents}"
				}
				True {
					CaptureChannels 4
				}
			}
			CaptureMixerElem "Dmic0"
			CaptureVolume "Dmic0 Capture Volume"
			CaptureSwitch "Dmic0 Capture Switch"
		}
	}
}

SectionDevice."Speaker" {
	Comment "Speakers"

	ConflictingDevice [
		"Headphones"
	]

	EnableSequence [
		cset "name='Speaker Switch' on"
	]

	DisableSequence [
		cset "name='Speaker Switch' off"
	]

	Value {
		PlaybackPriority 100
		PlaybackPCM "hw:${CardId}"
		# The es8316 only has a HP-amp which is muxed to the speaker
		# or to the headpones output
		PlaybackMixerElem "Headphone Mixer"
		PlaybackMasterElem "DAC"
	}
}

SectionDevice."Headphones" {
	Comment "Headphones"

	ConflictingDevice [
		"Speaker"
	]

	EnableSequence [
		cset "name='Headphone Switch' on"
	]

	DisableSequence [
		cset "name='Headphone Switch' off"
	]

	Value {
		PlaybackPriority 300
		PlaybackPCM "hw:${CardId}"
		PlaybackMixerElem "Headphone Mixer"
		PlaybackMasterElem "DAC"
		JackControl "Headphone Jack"
		JackHWMute "Speaker"
	}
}

SectionDevice."Headset" {
	Comment "Headset Microphone"

	If.conflict {
		Condition {
			Type String
			Empty "${var:DeviceDmic}"
		}
		True.ConflictingDevice [
			"Mic"
		]
	}

	EnableSequence [
		cset "name='Headset Mic Switch' on"
		cset "name='Digital Mic Mux' 'dmic disable'"
	]

	DisableSequence [
		cset "name='Headset Mic Switch' off"
	]

	Value {
		CapturePriority 300
		CapturePCM "hw:${CardId}"
		CaptureMixerElem "ADC PGA Gain"
		CaptureMasterElem "ADC"
		JackControl "Headset Mic Jack"
	}
}

Include.hdmi.File "/Intel/sof-essx8336/Hdmi.conf"
