#
# Macro HDMI
#
# Arguments:
#
#   Number        HDMI number
#   Device        PCM device number
#   Priority      UCM device priority
#

DefineMacro.HDMI {
	If.1 {
		Condition {
			Type RegexMatch
			Regex "(^$|0)"
			String "${var:-__Device}"
		}
		True.Define.__Suffix ""
		False.Define.__Suffix ",pcm=${var:__Device}"
	}
	If.2 {
		Condition {
			Type ControlExists
			Control "iface=CARD,name='HDMI/DP${var:__Suffix} Jack'"
		}
		True.SectionDevice."HDMI${var:__Number}" {
			Comment "HDMI / DisplayPort ${var:__Number} Output"

			EnableSequence [
				cset "name='IEC958 Playback Switch',index=${eval:($__Number-1)} on"
			]

			DisableSequence [
				cset "name='IEC958 Playback Switch',index=${eval:($__Number-1)} off"
			]

			Value {
				PlaybackPriority "${var:__Priority}"
				PlaybackPCM "hw:${CardId},${var:__Device}"
				JackControl "HDMI/DP${var:__Suffix} Jack"
			}
		}
	}
}
