# 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
Define.MainCardId "rockchipes8326c"

SectionVerb {
	EnableSequence [
		exec "/usr/bin/logger -t UCM -p info HiFi_dvt:SectionVerb:EnableSequence"
		cdev "hw:${var:MainCardId}"
		cset "name='Speakers Switch' off"
		cset "name='Main Mic Switch' off"
		cset "name='Headphone Switch' off"
		cset "name='Headset Mic Switch' off"
	]
}

SectionDevice."Headphones" {
	Comment "Headphones"

	EnableSequence [
		exec "/usr/bin/logger -t UCM -p info HiFi_dvt:Headphones:EnableSequence"
		cdev "hw:${var:MainCardId}"
		cset "name='Headphone Switch' on"
	]

	DisableSequence [
		exec "/usr/bin/logger -t UCM -p info HiFi_dvt:Headphones:DisableSequence"
		cdev "hw:${var:MainCardId}"
		cset "name='Headphone Switch' off"
	]

	Value {
		PlaybackPriority 200
		PlaybackPCM "hw:${var:MainCardId}"
		PlaybackMasterElem "DAC Playback Volume"
		PlaybackVolume "DAC Playback Volume"
		PlaybackSwitch "Headphone Switch"
		JackControl "Headphone Jack"
		JackHWMute "Speakers"
	}
}

SectionDevice."Headset" {
	Comment "Headset"

	EnableSequence [
		exec "/usr/bin/logger -t UCM -p info HiFi_dvt:Headset:EnableSequence"
		cdev "hw:${var:MainCardId}"
		cset "name='Headphone Switch' on"
		cset "name='Headset Mic Switch' on"
	]

	DisableSequence [
		exec "/usr/bin/logger -t UCM -p info HiFi_dvt:Headset:DisableSequence"
		cdev "hw:${var:MainCardId}"
		cset "name='Headphone Switch' off"
		cset "name='Headset Mic Switch' off"
	]

	Value {
		CapturePriority 200
		CapturePCM "hw:${var:MainCardId}"
		CaptureMasterElem "ADC Capture Volume"
		CaptureVolume "ADC Capture Volume"
		CaptureSwitch "Headset Mic Switch"
		JackControl "Headset Mic Jack"
	}
}
