SectionVerb {
	Value {
		TQ "HiFi"
	}

	EnableSequence [
		cset "name='Front Playback Switch' off"
		cset "name='Rear-Panel Capture Switch' off"
		cset "name='Headphone Playback Switch' off"
	]

	DisableSequence [
		cset "name='Front Playback Switch' off"
		cset "name='Front-Panel Capture Switch' off"
		cset "name='Rear-Panel Capture Switch' off"
	]
}

If.speaker {
	Condition {
		Type ControlExists
		Control "name='Speaker Playback Switch'"
	}
	True {
		SectionVerb {
			EnableSequence [
				cset "name='Speaker Playback Switch' on"
			]
			DisableSequence [
				cset "name='Speaker Playback Switch' off"
			]
		}

		SectionDevice."Speaker" {
			Comment "Speaker"

			Value {
				PlaybackPriority 100
				PlaybackPCM "hw:${CardId},4"
				PlaybackMixerElem "Speaker"
			}

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

			ConflictingDevice [
				"Headphones"
			]
		}
	}
}

SectionDevice."Line1" {
	Comment "Line Out"

	Value {
		PlaybackPriority 200
		PlaybackPCM "hw:${CardId}"
	}

	If.0 {
		Condition {
			Type ControlExists
			Control "name='Front Playback Switch'"
		}
		True.Value.PlaybackMixerElem "Front"
	}
	# make S/PDIF output working when no analog jacks are connected
	If.speaker {
		Condition {
			Type ControlExists
			Control "name='Speaker Playback Switch'"
		}
		True.If.1 {
			Condition {
				Type ControlExists
				Control "iface=CARD,name='Line Out Front Jack'"
			}
			True.Value.JackControl "Line Out Front Jack"
			False.Value.JackControl "Line Out Jack"
		}
	}
}

SectionDevice."Headphones" {
	Comment "Headphones"

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

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

	Value {
		PlaybackPriority 300
		PlaybackPCM "hw:${CardId},4"
		PlaybackMixerElem "Headphone"
		JackControl "Front Headphone Jack"
	}

	If.speaker {
		Condition {
			Type ControlExists
			Control "name='Speaker Playback Switch'"
		}
		True.Value.JackHWMute "Speaker"
	}
}

SectionDevice."Line2" {
	Comment "Rear Line In"

	ConflictingDevice [
		"Mic2"
	]

	EnableSequence [
		cset "name='Input Source' Line"
	]

	Value {
		CapturePriority 200
		CapturePCM "hw:${CardId}"
		CaptureMixerElem "Rear-Panel"
		CaptureMasterElem "Line Boost"
		JackControl "Line Jack"
	}
}

SectionDevice."Mic2" {
	Comment "Rear Microphone"

	Value {
		CapturePriority 300
		CapturePCM "hw:${CardId}"
		CaptureMixerElem "Rear-Panel"
		CaptureMasterElem "Rear Mic Boost"
		JackHWMute "Line2"
		JackControl "Rear Mic Jack"
	}

	EnableSequence [
		cset "name='Input Source' 'Rear Mic'"
	]
}

SectionDevice."Mic1" {
	Comment "Front Microphone"

	Value {
		CapturePriority 100
		CapturePCM "hw:${CardId},4"
		CaptureMixerElem "Front-Panel"
		CaptureMasterElem "Front Mic Boost"
		JackControl "Front Mic Jack"
	}
}
