# Use case Configuration for bytcr-rt5640

Define.HaveAif ""
Define.HaveSpeaker ""
Define.HaveHeadPhones2 ""
Define.HaveInternalMic ""
Define.HaveHeadsetMic "yes"
Define.HaveHeadsetMic2 ""
Define.StereoADC2Mux "DMIC1"

If.DefineAif1 {
	Condition {
		Type String
		Haystack "${CardComponents}"
		Needle "aif:1"
	}
	True.Define.HaveAif "1"
}

If.DefineAif2 {
	Condition {
		Type String
		Haystack "${CardComponents}"
		Needle "aif:2"
	}
	True.Define.HaveAif "2"
}

If.0 {
	Condition {
		Type String
		Haystack "${CardComponents}"
		Needle "cfg-spk:"
	}
	True.Include.comp.File "/Intel/bytcr-rt5640/HiFi-Components.conf"
	False.Include.long.File "/Intel/bytcr-rt5640/HiFi-LongName.conf"
}

SectionVerb {
	Include.e.File "/codecs/rt5640/EnableSeq.conf"

	EnableSequence [
		cset "name='Speaker Switch' off"
		cset "name='Headphone Switch' off"
		cset "name='Headset Mic Switch' off"
		cset "name='Internal Mic Switch' off"
	]

	If.Controls {
		Condition {
			Type ControlExists
			Control "name='media0_in Gain 0 Switch'"
		}
		Before.EnableSequence "0"
		True {
			Include.pe.File "/platforms/bytcr/PlatformEnableSeq.conf"
			Include.pd.File "/platforms/bytcr/PlatformDisableSeq.conf"
		}
	}
}

If.spk {
	Condition {
		Type String
		Haystack "${var:HaveSpeaker}"
		Needle "2"
	}
	True {
		Include.spk.File "/codecs/rt5640/Speaker.conf"

		SectionDevice."Speaker" {
			EnableSequence [
				cset "name='Speaker Switch' on"
			]

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

If.mono {
	Condition {
		Type String
		Haystack "${var:HaveSpeaker}"
		Needle "1"
	}
	True {
		Include.mspk.File "/codecs/rt5640/MonoSpeaker.conf"

		SectionDevice."Speaker" {
			EnableSequence [
				cset "name='Speaker Switch' on"
			]

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

If.hp {
	Condition { Type String Empty "" }
	True {
		Include.hs.File "/codecs/rt5640/HeadPhones.conf"

		SectionDevice."Headphones" {
			EnableSequence [
				cset "name='Headphone Switch' on"
			]

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

If.hp2 {
	Condition { Type String Empty "${var:HaveHeadPhones2}" }
	False {
		Include.hs.File "/codecs/rt5640/HeadPhones2.conf"

		SectionDevice."Headphones2" {
			EnableSequence [
				cset "name='Line Out Switch' on"
			]

			DisableSequence [
				cset "name='Line Out Switch' off"
			]
		}
	}
}

If.dmic {
	Condition {
		Type String
		Haystack "${var:HaveInternalMic}"
		Needle "dmic"
	}
	True {
		Include.dmic.File "/codecs/rt5640/DigitalMics.conf"

		SectionDevice."Mic" {
			EnableSequence [
				cset "name='Internal Mic Switch' on"
			]

			DisableSequence [
				cset "name='Internal Mic Switch' off"
			]
		}
	}
}

If.in1 {
	Condition {
		Type String
		Haystack "${var:HaveInternalMic}"
		Needle "in1"
	}
	True {
		Include.mic1.File "/codecs/rt5640/IN1-InternalMic.conf"

		SectionDevice."Mic" {
			EnableSequence [
				cset "name='Internal Mic Switch' on"
			]

			DisableSequence [
				cset "name='Internal Mic Switch' off"
			]
		}
	}
}

If.in3 {
	Condition {
		Type String
		Haystack "${var:HaveInternalMic}"
		Needle "in3"
	}
	True {
		Include.mic3.File "/codecs/rt5640/IN3-InternalMic.conf"

		SectionDevice."Mic" {
			EnableSequence [
				cset "name='Internal Mic Switch' on"
			]

			DisableSequence [
				cset "name='Internal Mic Switch' off"
			]
		}
	}
}

If.hsmic {
	Condition { Type String Empty "" }
	True {
		Include.hsmic.File "/codecs/rt5640/HeadsetMic.conf"

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

			DisableSequence [
				cset "name='Headset Mic Switch' off"
			]
		}
	}
}

If.hsmic2 {
	Condition {
		Type String
		Haystack "${var:HaveHeadsetMic2}"
		Needle "in1"
	}
	True {
		Include.hsmic.File "/codecs/rt5640/HeadsetMic2-IN1.conf"

		SectionDevice."Headset2" {
			EnableSequence [
				cset "name='Headset Mic 2 Switch' on"
			]

			DisableSequence [
				cset "name='Headset Mic 2 Switch' off"
			]
		}
	}
}
