# Reference:
# https://gitlab.manjaro.org/manjaro-arm/packages/community/pinebookpro-post-install/-/blob/4b4206c57b21044bf9c00848bd1f8b6f710d19eb/asound.state
# https://gitlab.manjaro.org/manjaro-arm/packages/community/pinebookpro-audio/-/blob/1f567db09495acc3beb5405c9ef85c3c07b86785/audio_jack_plugged_in.sh

SectionDevice."Speaker" {
	Comment "Speaker"

	ConflictingDevice [
		"Headphones"
	]

	EnableSequence [
		cset "name='Playback Polarity' 'R Invert'"
		cset "name='Speaker Switch' on"
	]

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

	Value {
		PlaybackPriority 100
		PlaybackPCM "hw:${CardId}"
		PlaybackMixerElem "Headphone Mixer"
		PlaybackMasterElem "DAC"
	}
}

SectionDevice."Mic" {
	Comment "Internal Microphone"

	EnableSequence [
		cset "name='Differential Mux' lin1-rin1"
	]

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

SectionDevice."Headphones" {
	Comment "Headphones"

	ConflictingDevice [
		"Speaker"
	]

	EnableSequence [
		cset "name='Playback Polarity' 'Normal'"
	]
	DisableSequence [
		cset "name='Playback Polarity' 'R Invert'"
	]

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