1c72fcc34Sopenharmony_ci#!/bin/bash 2c72fcc34Sopenharmony_ci 3c72fcc34Sopenharmony_ci#/* 4c72fcc34Sopenharmony_ci# * Copyright (C) 2013-2016 Intel Corporation 5c72fcc34Sopenharmony_ci# * 6c72fcc34Sopenharmony_ci# * This program is free software; you can redistribute it and/or modify 7c72fcc34Sopenharmony_ci# * it under the terms of the GNU General Public License as published by 8c72fcc34Sopenharmony_ci# * the Free Software Foundation; either version 2 of the License, or 9c72fcc34Sopenharmony_ci# * (at your option) any later version. 10c72fcc34Sopenharmony_ci# * 11c72fcc34Sopenharmony_ci# * This program is distributed in the hope that it will be useful, 12c72fcc34Sopenharmony_ci# * but WITHOUT ANY WARRANTY; without even the implied warranty of 13c72fcc34Sopenharmony_ci# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14c72fcc34Sopenharmony_ci# * GNU General Public License for more details. 15c72fcc34Sopenharmony_ci# * 16c72fcc34Sopenharmony_ci# */ 17c72fcc34Sopenharmony_ci#set -x 18c72fcc34Sopenharmony_ci 19c72fcc34Sopenharmony_cisubdevice_number=0 20c72fcc34Sopenharmony_ciget_subdevice=0 21c72fcc34Sopenharmony_ci 22c72fcc34Sopenharmony_ci#make sure the DP monitor is connected and active 23c72fcc34Sopenharmony_ci 24c72fcc34Sopenharmony_ci# To get DisplayPort audio device number 25c72fcc34Sopenharmony_cicard_number=$(aplay -l | grep "HDMI 1" | cut -b 6) 26c72fcc34Sopenharmony_ciecho $card_number 27c72fcc34Sopenharmony_ciif [ "$card_number" = "" ]; then 28c72fcc34Sopenharmony_ci echo "Can not get Display audio card." 29c72fcc34Sopenharmony_ci exit 254 30c72fcc34Sopenharmony_cifi 31c72fcc34Sopenharmony_ci 32c72fcc34Sopenharmony_ciaudio_card_dir="/proc/asound/card$card_number/" 33c72fcc34Sopenharmony_ci 34c72fcc34Sopenharmony_cicd $audio_card_dir 35c72fcc34Sopenharmony_ci 36c72fcc34Sopenharmony_cifor file in `ls` 37c72fcc34Sopenharmony_cido 38c72fcc34Sopenharmony_ci #To get the ELD info according to the connented monitor with DisplayPort. 39c72fcc34Sopenharmony_ci if [[ $file == eld* ]]; then 40c72fcc34Sopenharmony_ci let subdevice_number+=1 41c72fcc34Sopenharmony_ci cat $file | grep connection_type | grep DisplayPort > /dev/null 42c72fcc34Sopenharmony_ci if [ $? = 0 ]; then 43c72fcc34Sopenharmony_ci echo "Get the ELD information according to the connented \ 44c72fcc34Sopenharmony_cimonitor with DisplayPort." 45c72fcc34Sopenharmony_ci get_subdevice=1 46c72fcc34Sopenharmony_ci break 47c72fcc34Sopenharmony_ci fi 48c72fcc34Sopenharmony_ci fi 49c72fcc34Sopenharmony_cidone 50c72fcc34Sopenharmony_ci 51c72fcc34Sopenharmony_ci#failed to get the subdevice number of DisplayPort audio 52c72fcc34Sopenharmony_ciif [ $get_subdevice == 0 ]; then 53c72fcc34Sopenharmony_ci exit 77 54c72fcc34Sopenharmony_cifi 55c72fcc34Sopenharmony_ci 56c72fcc34Sopenharmony_ci#the subdevice number of DisplayPort audio is 3 57c72fcc34Sopenharmony_ciif [ $subdevice_number == 1 ]; then 58c72fcc34Sopenharmony_ci exit 3 59c72fcc34Sopenharmony_ci#the subdevice number of DisplayPort audio is 7. 60c72fcc34Sopenharmony_cielif [ $subdevice_number == 2 ]; then 61c72fcc34Sopenharmony_ci exit 7 62c72fcc34Sopenharmony_ci#the subdevice number of DisplayPort audio is 8 63c72fcc34Sopenharmony_cielif [ $subdevice_number == 3 ]; then 64c72fcc34Sopenharmony_ci exit 8 65c72fcc34Sopenharmony_ci#default: failed to get the subdevice number of DisplayPort audio 66c72fcc34Sopenharmony_cielse 67c72fcc34Sopenharmony_ci exit 77 68c72fcc34Sopenharmony_cifi 69