# Generic HDA devices for analog I/O

SectionVerb {
	EnableSequence [
		disdevall ""
	]

	Value.TQ "HiFi"
}

Define.loctl "Line"
Define.lovol "Line"
Define.hpvol "Headphone"
Define.hpjack "Headphone Jack"

#------------------LineOut Device begin-------------------------
If.lineout1 {
	Condition {
		Type ControlExists
		Control "name='Line Out Playback Volume'"
	}
	True.Define {
		loctl "Line Out"
		lovol "Line Out"
	}
	False.If.lineout2 {
		Condition {
			Type ControlExists
			Control "name='Speaker+LO Playback Volume'"
		}
		True.Define {
			loctl "Speaker+LO"
			lovol "Speaker+LO"
		}
	}
}

If.lineoutjack {
	Condition {
		Type ControlExists
		Control "iface=CARD,name='Line Out Jack'"
	}
	True.Define.lineoutjack "Line Out Jack"
}

SectionDevice."LineOut" {
	Comment "Line Out"

	ConflictingDevice [
		"Headphones"
	]

	EnableSequence [
		cset "name='${var:loctl} Playback Switch' on"
	]

	DisableSequence [
		cset "name='${var:loctl} Playback Switch' off"
	]

	Value {
			PlaybackPriority 300
			PlaybackPCM "hw:${CardId}"
			PlaybackChannels "2"
			PlaybackMixerElem "${var:lovol}"
			PlaybackMasterElem "Master"
			PlaybackVolume "${var:lovol} Playback Volume"
			PlaybackSwitch "${var:loctl} Playback Switch"
			JackControl "${var:lineoutjack}"
	}
}
#------------------LineOut Device end-------------------------

#------------------Headphones Device begin--------------------
If.hpjack {
	Condition {
		Type ControlExists
		Control "iface=CARD,name='Headphone Mic Jack'"
	}
	True.Define.hpjack "Headphone Mic Jack"
	False.If.front {
		Condition {
			Type ControlExists
			Control "iface=CARD,name='Front Headphone Jack'"
		}
		True.Define.hpjack "Front Headphone Jack"
	}
}

SectionDevice."Headphones" {
	Comment "Headphones"

	ConflictingDevice [
		"LineOut"
	]

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

	Value {
		PlaybackPriority 200
		PlaybackPCM "hw:${CardId}"
		PlaybackChannels "2"
		PlaybackMixerElem "${var:hpvol}"
		PlaybackMasterElem "Master"
		PlaybackVolume "${var:hpvol} Playback Volume"
		PlaybackSwitch "Headphone Playback Switch"
		JackControl "${var:hpjack}"
	}
}
#------------------Headphones Device end--------------------

#------------------Mic Devices begin------------------------
SectionDevice."LineIn" {
	Comment "Line In"

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

	EnableSequence [
		cset "name='Input Source' 'Line'"
		cset "name='Line Playback Switch' on"
	]

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

	Value {
		CapturePriority 100
		CapturePCM "hw:${CardId}"
		CaptureChannels "2"
		CaptureMixerElem "Capture"
		CaptureMasterElem "Line Boost"
		JackControl "Line Jack"
	}
}

SectionDevice."RearMic" {
	Comment "Rear Mic"

	EnableSequence [
		cset "name='Input Source' 'Rear Mic'"
		cset "name='Rear Mic Playback Switch' on"
	]

	DisableSequence [
		cset "name='Rear Mic Playback Switch' off"
	]

	Value {
		CapturePriority 200
		CapturePCM "hw:${CardId}"
		CaptureChannels "2"
		CaptureMixerElem "Capture"
		CaptureMasterElem "Rear Mic Boost"
		JackControl "Rear Mic Jack"
	}
}

SectionDevice."FrontMic" {
	Comment "Front Mic"

	EnableSequence [
		cset "name='Input Source' Front Mic"
		cset "name='Front Mic Playback Switch' on"
	]

	DisableSequence [
		cset "name='Front Mic Playback Switch' off"
	]

	Value {
		CapturePriority 300
		CapturePCM "hw:${CardId}"
		CaptureChannels "2"
		CaptureMixerElem "Capture"
		CaptureMasterElem "Front Mic Boost"
		JackControl "Front Mic Jack"
	}
}
#------------------Mic Devices end------------------------
