summaryrefslogtreecommitdiff
path: root/snd-alpx-dkms/snd-alpx/tools/build_virtual_board_alsa_conf.sh
diff options
context:
space:
mode:
Diffstat (limited to 'snd-alpx-dkms/snd-alpx/tools/build_virtual_board_alsa_conf.sh')
-rwxr-xr-xsnd-alpx-dkms/snd-alpx/tools/build_virtual_board_alsa_conf.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/snd-alpx-dkms/snd-alpx/tools/build_virtual_board_alsa_conf.sh b/snd-alpx-dkms/snd-alpx/tools/build_virtual_board_alsa_conf.sh
new file mode 100755
index 0000000..3e8a605
--- /dev/null
+++ b/snd-alpx-dkms/snd-alpx/tools/build_virtual_board_alsa_conf.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+## This script will print an asoundrc stream which add virtual boards from one physical board.
+## Output must be directed into a file to be stored
+
+### FUNCTIONS ###
+user_manual() {
+ echo "Required Parameters
+ 1. Phy board id like "hw:CARD=Alp882e,DEV=0"
+ 2. Phy board channels quantity
+ 3. Virtual boards base name like : \"Emulated analog Alp222\"
+ 4. Virtual boards channels quantities (2: stéréo, ...)" >&2
+}
+
+
+build_phy_node() {
+ node_type=$1
+ card_id=$2
+ channels_qty=$3
+ echo -e "pcm_slave.$node_type { \n pcm \"$card_id\"\n channels $channels_qty\n }\n"
+}
+
+build_virtual_node() {
+node_alias=$1
+node_type=$2
+node_id=$3
+ipc_key=$4
+phy_name=$5
+phy_channels_base=$6
+phy_channels_qty=$7
+description=$8
+direction=$9
+
+echo -e "pcm.$node_alias$node_id {
+ type $node_type
+ ipc_key $ipc_key
+ ipc_key_add_uid true
+ slave $phy_name"
+
+ for channel_id in $(seq 0 "$(($phy_channels_qty-1))")
+ do
+ echo -e "\tbindings.$channel_id $(($channel_id+$phy_channels_base))"
+ done
+
+
+ echo -e "\thint.description" \"$description \#$node_id $direction\"
+ echo -e "}\n"
+}
+
+### MAIN ###
+
+[ "$#" -ne "4" ] && user_manual && exit 1
+
+ipc_key=$(date +%N)
+card_id=$1
+channels_qty=$2
+virtual_basename=$3
+stream_width=$4
+virt_qty=$(($channels_qty / $stream_width))
+
+echo "#Building Alsa sound RC file for $virt_qty virtual boards of $stream_width channels from physical board $card_id with $channels_qty."
+
+##Build the entries first
+build_phy_node "ins" "$card_id" "$channels_qty"
+
+for entry_idx in $(seq 0 $(($virt_qty-1)))
+do
+ build_virtual_node "mic" "dsnoop" "$entry_idx" "$ipc_key" "ins" "$(($stream_width * $entry_idx))" "$stream_width" "virtual Alp-$stream_width" "in"
+done
+
+##Now the outpus
+build_phy_node "outs" "$card_id" "$channels_qty"
+
+ipc_key=$(date +%N)
+
+for entry_idx in $(seq 0 $(($virt_qty-1)))
+do
+ build_virtual_node "out" "dshare" "$entry_idx" "$ipc_key" "outs" "$(($stream_width * $entry_idx))" "$stream_width" "virtual Alp-$stream_width" "out"
+done
+