void packets_AudioInfoFrame(u16 baseAddr, audioParams_t *params) { LOG_TRACE(); halFrameComposerAudioInfo_ChannelCount(baseAddr + FC_BASE_ADDR, audioParams_ChannelCount( params)); halFrameComposerAudioInfo_AllocateChannels(baseAddr + FC_BASE_ADDR, audioParams_GetChannelAllocation(params)); halFrameComposerAudioInfo_LevelShiftValue(baseAddr + FC_BASE_ADDR, audioParams_GetLevelShiftValue(params)); halFrameComposerAudioInfo_DownMixInhibit(baseAddr + FC_BASE_ADDR, audioParams_GetDownMixInhibitFlag(params)); if ((audioParams_GetCodingType(params) == ONE_BIT_AUDIO) || (audioParams_GetCodingType(params) == DST)) { /* Audio InfoFrame sample frequency when OBA or DST */ if (audioParams_GetSamplingFrequency(params) == 32000) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 1); } else if (audioParams_GetSamplingFrequency(params) == 44100) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 2); } else if (audioParams_GetSamplingFrequency(params) == 48000) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 3); } else if (audioParams_GetSamplingFrequency(params) == 88200) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 4); } else if (audioParams_GetSamplingFrequency(params) == 96000) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 5); } else if (audioParams_GetSamplingFrequency(params) == 176400) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 6); } else if (audioParams_GetSamplingFrequency(params) == 192000) { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 7); } else { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 0); } } else { halFrameComposerAudioInfo_SampleFreq(baseAddr + FC_BASE_ADDR, 0); /* otherwise refer to stream header (0) */ } halFrameComposerAudioInfo_CodingType(baseAddr + FC_BASE_ADDR, 0); /* for HDMI refer to stream header (0) */ halFrameComposerAudioInfo_SamplingSize(baseAddr + FC_BASE_ADDR, 0); /* for HDMI refer to stream header (0) */ }
/** * Check audio parameters against read EDID structure to ensure * compatibility with sink. * @param audio audio parameters data structure */ static int api_CheckParamsAudio(audioParams_t * audio) { unsigned i = 0; int bitSupport = -1; shortAudioDesc_t sad; speakerAllocationDataBlock_t allocation; u8 errorCode = TRUE; int valid = FALSE; /* array to translate from AudioInfoFrame code to EDID Speaker Allocation data block bits */ const u8 sadb[] = { 1, 3, 5, 7, 17, 19, 21, 23, 9, 11, 13, 15, 25, 27, 29, 31, 73, 75, 77, 79, 33, 35, 37, 39, 49, 51, 53, 55, 41, 43, 45, 47 }; LOG_TRACE(); if (!api_EdidSupportsBasicAudio()) { error_Set(ERR_SINK_DOES_NOT_SUPPORT_AUDIO); printk("Sink does NOT support audio"); return FALSE; } /* check if audio type supported */ for (i = 0; i < api_EdidSadCount(); i++) { api_EdidSad(i, &sad); if (audioParams_GetCodingType(audio) == shortAudioDesc_GetFormatCode( &sad)) { bitSupport = i; break; } } if (bitSupport >= 0) { api_EdidSad(bitSupport, &sad); /* 192 kHz| 176.4 kHz| 96 kHz| 88.2 kHz| 48 kHz| 44.1 kHz| 32 kHz */ switch (audioParams_GetSamplingFrequency(audio)) { case 32000: valid = shortAudioDesc_Support32k(&sad); break; case 44100: valid = shortAudioDesc_Support44k1(&sad); break; case 48000: valid = shortAudioDesc_Support48k(&sad); break; case 88200: valid = shortAudioDesc_Support88k2(&sad); break; case 96000: valid = shortAudioDesc_Support96k(&sad); break; case 176400: valid = shortAudioDesc_Support176k4(&sad); break; case 192000: valid = shortAudioDesc_Support192k(&sad); break; default: valid = FALSE; break; } if (!valid) { error_Set(ERR_SINK_DOES_NOT_SUPPORT_AUDIO_SAMPLING_FREQ); LOG_WARNING2("Sink does NOT support audio sampling frequency", audioParams_GetSamplingFrequency(audio)); errorCode = FALSE; } if (audioParams_GetCodingType(audio) == PCM) { /* 24 bit| 20 bit| 16 bit */ switch (audioParams_GetSampleSize(audio)) { case 16: valid = shortAudioDesc_Support16bit(&sad); break; case 20: valid = shortAudioDesc_Support20bit(&sad); break; case 24: valid = shortAudioDesc_Support24bit(&sad); break; default: valid = FALSE; break; } if (!valid) { error_Set(ERR_SINK_DOES_NOT_SUPPORT_AUDIO_SAMPLE_SIZE); LOG_WARNING2("Sink does NOT support audio sample size", audioParams_GetSampleSize(audio)); errorCode = FALSE; } } /* check Speaker Allocation */ if (api_EdidSpeakerAllocationDataBlock(&allocation) == TRUE) { LOG_DEBUG2("Audio channel allocation sent", sadb[audioParams_GetChannelAllocation(audio)]); LOG_DEBUG2("Audio channel allocation accepted", speakerAllocationDataBlock_GetSpeakerAllocationByte(&allocation)); valid = (sadb[audioParams_GetChannelAllocation(audio)] & speakerAllocationDataBlock_GetSpeakerAllocationByte( &allocation)) == sadb[audioParams_GetChannelAllocation(audio)]; if (!valid) { error_Set(ERR_SINK_DOES_NOT_SUPPORT_ATTRIBUTED_CHANNELS); printk("Sink does NOT have attributed speakers"); errorCode = FALSE; } } } else { error_Set(ERR_SINK_DOES_NOT_SUPPORT_AUDIO_TYPE); printk("Sink does NOT support audio type"); errorCode = FALSE; } return errorCode; }