tarina

git clone https://git.tarina.org/tarina
Log | Files | Refs | README | LICENSE

hdmi_audio_subdevice_number.sh (1688B)


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