1#!/bin/sh
2
3# Copyright (c) 2011-2014, Intel Corporation
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without modification,
7# are permitted provided that the following conditions are met:
8#
9# 1. Redistributions of source code must retain the above copyright notice, this
10# list of conditions and the following disclaimer.
11#
12# 2. Redistributions in binary form must reproduce the above copyright notice,
13# this list of conditions and the following disclaimer in the documentation and/or
14# other materials provided with the distribution.
15#
16# 3. Neither the name of the copyright holder nor the names of its contributors
17# may be used to endorse or promote products derived from this software without
18# specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31
32set -ue
33
34# Replace amixer in stdio by the parameter equivalent
35# A convertion table file must be passed in argument
36# It is design to be work with the output of scripts/sortAsound.conf.sh
37
38# a perl regexp that matches only alsa mixer lines
39regexp='^[^\s/]'
40
41if test $# != 1 || test ! -f $1
42then
43    echo "argument 1 must be a convertion file like this :
44/.../parameter1       alsa mixeur 1
45/.../parameter2       alsa mixeur 2
46..."
47    exit 1
48fi
49
50find_pfw_equivalent(){
51    if pfw_equivalent="$(grep $1 $2)"
52    then
53        echo $pfw_equivalent | sed 's/ .*//'
54    else
55        return 1
56    fi
57}
58
59
60while IFS=''; read -r line
61do
62    if echo "$line" | grep -qP "$regexp" && parameter="$(find_pfw_equivalent "$line" $1)"
63    then
64        echo "$parameter ( $line )"
65    else
66        echo "$line"
67    fi
68done
69