# Use case configuration for Xiaomi Pad 5
# Author: map220v <map220v300@gmail.com>
#
# Playback Devices
#  - Internal Speakers   : CS35L41 driver : MultiMedia1 <-> QUAT_TDM_RX_0
# Capture Devices
#  - Internal Bottom Mic : WCD9341 driver : MultiMedia2 <-> SLIMBUS_0_TX (AIF1_CAP, ADC1, TX6)
#  - Internal Top Mic 	 : WCD9341 driver : MultiMedia2 <-> SLIMBUS_0_TX (AIF1_CAP, ADC3, TX5)

SectionVerb {
    EnableSequence [
        # SPEAKER PLAYBACK
        cset "name='BR PCM Soft Ramp' 4ms"
        cset "name='TR PCM Soft Ramp' 4ms"
        cset "name='BL PCM Soft Ramp' 4ms"
        cset "name='TL PCM Soft Ramp' 4ms"
        cset "name='BR Analog PCM Volume' 8"
        cset "name='TR Analog PCM Volume' 8"
        cset "name='BL Analog PCM Volume' 8"
        cset "name='TL Analog PCM Volume' 8"
        # Enable Quaternary TDM0 mixer on MultiMedia1
        cset "name='QUAT_TDM_RX_0 Audio Mixer MultiMedia1' 1"

        # Bottom Mic
        cset "name='ADC1 Volume' 0"
        cset "name='AIF1_CAP Mixer SLIM TX6' 1"
        cset "name='CDC_IF TX6 MUX' DEC6"

        # Top Mic
        cset "name='ADC3 Volume' 0"
        cset "name='AIF1_CAP Mixer SLIM TX5' 1"
        cset "name='CDC_IF TX5 MUX' DEC5"
        cset "name='AMIC4_5 SEL' AMIC4"

        cset "name='MultiMedia2 Mixer SLIMBUS_0_TX' 1"
    ]

    DisableSequence [
        # Disable Quaternary TDM0 mixer on MultiMedia1
        cset "name='QUAT_TDM_RX_0 Audio Mixer MultiMedia1' 0"
        cset "name='MultiMedia2 Mixer SLIMBUS_0_TX' 0"

        cset "name='CDC_IF TX6 MUX' ZERO"
        cset "name='CDC_IF TX5 MUX' ZERO"
    ]

    # Set initial volumes
    BootSequence [
    ]

    Value {
        TQ "HiFi"
    }
}

SectionDevice."Speaker" {
    Comment "Speaker playback"

    Value {
        PlaybackPriority 150
        PlaybackPCM "hw:${CardId},0"
        PlaybackChannels 2
    }
}

SectionDevice."Mic" {
	Comment "Internal Microphones"

	EnableSequence [
		cset "name='ADC MUX6' AMIC"
		cset "name='ADC MUX5' AMIC"
		cset "name='AMIC MUX6' ADC1"
		cset "name='AMIC MUX5' ADC3"
		cset "name='ADC1 Volume' 0"
		cset "name='ADC3 Volume' 0"
	]

	DisableSequence [
		cset "name='AMIC MUX6' ZERO"
		cset "name='AMIC MUX5' ZERO"
		cset "name='ADC1 Volume' 0"
		cset "name='ADC3 Volume' 0"
	]

	Value {
		CapturePriority 200
		CapturePCM "hw:${CardId},1" # MultiMedia2
		PlaybackChannels 2
	}
}

