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"
	]
}

If.dacmonomix {
	Condition {
		Type ControlExists
		Control "name='DAC Mono Mix Switch'"
	}
	True {
		cset "name='DAC Mono Mix Switch' off"
	}
}

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

		ConflictingDevice [
			"Headset"
		]

		If.micmux {
			Condition {
				Type ControlExists
				Control "name='Mic Mux'"
			}
			True {
				cset "name='Mic Mux' 'DMIC SDINOUT2'"
			}
		}

		If.diffmux {
			Condition {
				Type ControlExists
				Control "name='Differential Mux'"
			}
			True {
				cset "name='Differential Mux' lin1-rin1"
			}
		}

		EnableSequence [
			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"
		cset "name='DAC Playback Volume' 70%"
	]

	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"
		]
	}

	If.micmux {
		Condition {
			Type ControlExists
			Control "name='Mic Mux'"
		}
		True {
			cset "name='Mic Mux' 'Analog MIC'"
		}
	}

	If.diffmux {
		Condition {
			Type ControlExists
			Control "name='Differential Mux'"
		}
		True {
			cset "name='Differential Mux' lin2-rin2"
		}
	}

	EnableSequence [
		cset "name='Headset Mic Switch' on"
	]

	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"
