1 /* AudioUtil.h 2 * 3 * Copyright (C) 2012 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef ALSA_SOUND_AUDIO_UTIL_H 19 #define ALSA_SOUND_AUDIO_UTIL_H 20 21 #define BIT(nr) (1UL << (nr)) 22 #define MAX_EDID_BLOCKS 10 23 #define MAX_SHORT_AUDIO_DESC_CNT 30 24 #define MIN_AUDIO_DESC_LENGTH 3 25 #define MIN_SPKR_ALLOCATION_DATA_LENGTH 3 26 27 typedef enum EDID_AUDIO_FORMAT_ID { 28 LPCM = 1, 29 AC3, 30 MPEG1, 31 MP3, 32 MPEG2_MULTI_CHANNEL, 33 AAC, 34 DTS, 35 ATRAC, 36 SACD, 37 DOLBY_DIGITAL_PLUS, 38 DTS_HD, 39 MAT, 40 DST, 41 WMA_PRO 42 } EDID_AUDIO_FORMAT_ID; 43 44 typedef struct EDID_AUDIO_BLOCK_INFO { 45 EDID_AUDIO_FORMAT_ID nFormatId; 46 int nSamplingFreq; 47 int nBitsPerSample; 48 int nChannels; 49 } EDID_AUDIO_BLOCK_INFO; 50 51 typedef struct EDID_AUDIO_INFO { 52 int nAudioBlocks; 53 unsigned char nSpeakerAllocation[MIN_SPKR_ALLOCATION_DATA_LENGTH]; 54 EDID_AUDIO_BLOCK_INFO AudioBlocksArray[MAX_EDID_BLOCKS]; 55 } EDID_AUDIO_INFO; 56 57 class AudioUtil { 58 public: 59 60 //Parses EDID audio block when if HDMI is connected to determine audio sink capabilities. 61 static bool getHDMIAudioSinkCaps(EDID_AUDIO_INFO*); 62 63 private: 64 static int printFormatFromEDID(unsigned char format); 65 static int getSamplingFrequencyFromEDID(unsigned char byte); 66 static int getBitsPerSampleFromEDID(unsigned char byte, 67 unsigned char format); 68 static bool getSpeakerAllocation(EDID_AUDIO_INFO* pInfo); 69 }; 70 71 #endif /* ALSA_SOUND_AUDIO_UTIL_H */ 72