481 lines
15 KiB
C++
481 lines
15 KiB
C++
/*
|
|
* Copyright (C) 2017 Amlogic Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef _DOLBY_MS12_CONFIG_PARAMS_H_
|
|
#define _DOLBY_MS12_CONFIG_PARAMS_H_
|
|
|
|
|
|
#include <stdbool.h>
|
|
#include <system/audio.h>
|
|
|
|
#include "dolby_ms12_config_parameter_struct.h"
|
|
#include "dolby_ms12_output_mask.h"
|
|
#include "dolby_ms12_input_mask.h"
|
|
|
|
#define DEFAULT_DAP_TUNING_FILE_NAME "/vendor/etc/ms12_tuning.dat"
|
|
|
|
#ifdef __cplusplus
|
|
namespace android
|
|
{
|
|
|
|
#define MS12_INPUT_MAIN 0
|
|
#define MS12_INPUT_MAIN2 1
|
|
#define MS12_INPUT_SYSTEM 2
|
|
#define MS12_INPUT_APP 3
|
|
#define MS12_INPUT_UI 4
|
|
#define MS12_INPUT_MAX 5
|
|
|
|
#define MIN_USER_CONTROL_VALUES (-32)
|
|
#define MAX_USER_CONTROL_VALUES (32)
|
|
|
|
#define MAX_MS12_INPUT_CMD_LEN 16
|
|
|
|
#define MS12_VERSION_24 2
|
|
#define MS12_VERSION_28 3
|
|
|
|
typedef struct ms12InputNameMaskTable_t {
|
|
char fileTypeCmd[MAX_MS12_INPUT_CMD_LEN];
|
|
int mask;
|
|
}
|
|
ms12InputTable_t;
|
|
|
|
class DolbyMS12ConfigParams
|
|
{
|
|
|
|
public:
|
|
|
|
DolbyMS12ConfigParams();
|
|
virtual ~DolbyMS12ConfigParams();
|
|
// static DolbyMS12ConfigParams* getInstance();
|
|
|
|
|
|
// static DolbyMS12ConfigParams *getInstance();
|
|
virtual void SetAudioStreamOutParams(audio_output_flags_t flags
|
|
, audio_format_t input_format
|
|
, audio_channel_mask_t channel_mask
|
|
, int sample_rate
|
|
, int output_format);
|
|
virtual int SetInputOutputFileName(char **ConfigParams, int *row_index);
|
|
virtual int SetFunctionalSwitches(char **ConfigParams, int *row_index);
|
|
virtual int SetPCMSwitches(char **ConfigParams, int *row_index);
|
|
virtual int SetDAPDeviceSwitches(char **ConfigParams, int *row_index, int is_runtime);
|
|
virtual int SetDAPContentSwitches(char **ConfigParams, int *row_index);
|
|
virtual char **GetDolbyMS12ConfigParams(int *argc, Config_Arg_Type_e arg_type);
|
|
virtual char **UpdateDolbyMS12RuntimeConfigParams(int *argc, char *cmd);
|
|
|
|
//init the mConfigParams Array
|
|
virtual char **PrepareConfigParams(int max_raw_size, int max_column_size);
|
|
//cleanup the mConfigParams Array
|
|
virtual void CleanupConfigParams(char **ConfigParams, int max_raw_size);
|
|
|
|
virtual int GetDolbyConfigOutputConfig(void)
|
|
{
|
|
return mDolbyMS12OutConfig;
|
|
}
|
|
virtual int GetDolbyConfigOutputSampleRate(void)
|
|
{
|
|
return mDolbyMS12OutSampleRate;
|
|
}
|
|
virtual audio_channel_mask_t GetDolbyConfigOutputChannelMask(void)
|
|
{
|
|
return mDolbyMS12OutChannelMask[MS12_INPUT_MAIN];
|
|
}
|
|
//associate flags
|
|
virtual void ResetConfigParams(Config_Arg_Type_e arg_type);
|
|
|
|
virtual int ChannelMask2ChannelConfig(audio_channel_mask_t channel_mask);
|
|
virtual int ChannelMask2LFEConfig(audio_channel_mask_t channel_mask);
|
|
|
|
//*Begin||Add the APT to set the params*//
|
|
//Functional Switches
|
|
//virtual void setLowComplexityNode(bool flag) { mLowComplexityMode = flag; }//did not use this part!
|
|
virtual void setDRCboostVal(int val)
|
|
{
|
|
mDRCBoost = val;
|
|
}
|
|
virtual void setDRCcutVal(int val)
|
|
{
|
|
mDRCCut = val;
|
|
}
|
|
virtual void setDRCboostStereoVal(int val)
|
|
{
|
|
mDRCBoostStereo = val;
|
|
}
|
|
virtual void setDRCcutStereoVal(int val)
|
|
{
|
|
mDRCCutStereo = val;
|
|
}
|
|
virtual void setDAPV2InitialisationMode(int val)
|
|
{
|
|
mDAPInitMode = val; // 0 or 1
|
|
}
|
|
virtual void setDAPV2InitialisationDAPTuningFile(char* dap_tuning_file_name)
|
|
{
|
|
if (dap_tuning_file_name != NULL) {
|
|
mDAPTuningFile = dap_tuning_file_name;
|
|
ALOGI("+%s(): str=%s mDAPTuningFile=%s\n", __FUNCTION__, dap_tuning_file_name, mDAPTuningFile);
|
|
} else {
|
|
ALOGE("+%s():mDAPTuningFile=%s\n", __FUNCTION__, mDAPTuningFile);
|
|
}
|
|
}
|
|
virtual void setDRCMode(int val)
|
|
{
|
|
mDRCModesOfDownmixedOutput = val; // 0 or 1
|
|
}
|
|
virtual void setDAPDRCMode(int val)
|
|
{
|
|
mDAPDRCMode = val; // 0 or 1
|
|
}
|
|
virtual void setDownmixModes(int val)
|
|
{
|
|
mDownmixMode = val; // 0 or 1
|
|
}
|
|
virtual void setEvaluationMode(int val)
|
|
{
|
|
mEvaluationMode = val; // 0 or 1
|
|
}
|
|
virtual void setLFEpresentInSystemSoundsIn(int val)
|
|
{
|
|
mLFEPresentInSystemSoundIn = val; // 0 or 1
|
|
}
|
|
virtual void setDownmix71PCMto51OnMultiOutputs(int val)
|
|
{
|
|
mDonwnmix71PCMto51 = val; //0 or 1
|
|
}
|
|
virtual void setEncoderChannelModeLockingMode(int val)
|
|
{
|
|
mLockingChannelModeENC = val; //0 or 1
|
|
}
|
|
virtual int getEncoderChannelModeLockingMode()
|
|
{
|
|
return mLockingChannelModeENC; //0 or 1
|
|
}
|
|
|
|
virtual void setRISCprecisionFlag(int val)
|
|
{
|
|
mRISCPrecisionFlag = val;
|
|
}
|
|
|
|
virtual void setSystemAppAudioMixing(int val)
|
|
{
|
|
mSystemAPPAudioMixing = val;
|
|
//ALOGI("%s() mSystemAPPAudioMixing %d\n", __FUNCTION__, mSystemAPPAudioMixing);
|
|
}
|
|
virtual int getSystemAppAudioMixing(void)
|
|
{
|
|
return mSystemAPPAudioMixing;
|
|
}
|
|
virtual void setSystemSoundMixerGainValuesForAppSoundsInput(MixGain *mixergain)
|
|
{
|
|
if (mixergain) {
|
|
memcpy(&mSysAppsMixGain, mixergain, sizeof(MixGain));
|
|
if (mSysAppsMixGain.target < -12288) {
|
|
mSysAppsMixGain.target = -12288;
|
|
}
|
|
ALOGI("%s() set target %d duration %d shape %d", __FUNCTION__, mSysAppsMixGain.target, mSysAppsMixGain.duration, mSysAppsMixGain.shape);
|
|
}
|
|
}
|
|
virtual void setSystemSoundMixerGainValuesForSystemSoundsInput(MixGain *mixergain)
|
|
{
|
|
if (mixergain) {
|
|
memcpy(&mSysSyssMixGain, mixergain, sizeof(MixGain));
|
|
if (mSysSyssMixGain.target < -12288) {
|
|
mSysSyssMixGain.target = -12288;
|
|
}
|
|
ALOGI("%s() set target %d duration %d shape %d", __FUNCTION__, mSysSyssMixGain.target, mSysSyssMixGain.duration, mSysSyssMixGain.shape);
|
|
}
|
|
}
|
|
|
|
//DDPLUS SWITCHES
|
|
#if 0
|
|
virtual void setDDPAssociatedSubstreamSelection(int val)
|
|
{
|
|
mDdplusAssocSubstream = val;
|
|
}
|
|
#endif
|
|
//PCM SWITCHES
|
|
virtual void setPCMCompressorProfile(int val)
|
|
{
|
|
mCompressorProfile = val;
|
|
}
|
|
|
|
//DAP SWITCHES (device specific)
|
|
virtual void setDAPGains(int val)
|
|
{
|
|
mDAPGains = val;
|
|
}
|
|
virtual void setDAPSurroundDecoderEnable(bool val)
|
|
{
|
|
mDAPSurDecEnable = val;
|
|
}
|
|
virtual void setDAPSurroundVirtualizer(DAPSurroundVirtualizer *dapVirtualizerParameters)
|
|
{
|
|
if (dapVirtualizerParameters) {
|
|
memcpy(&DeviceDAPSurroundVirtualizer, dapVirtualizerParameters, sizeof(DeviceDAPSurroundVirtualizer));
|
|
}
|
|
}
|
|
virtual int getDAPSurroundVirtualizer(void)
|
|
{
|
|
return DeviceDAPSurroundVirtualizer.virtualizer_enable;
|
|
}
|
|
virtual void setDAPGraphicEQ(DAPGraphicEQ *dapGraphicEQParameters)
|
|
{
|
|
if (dapGraphicEQParameters) {
|
|
memcpy(&DeviceDAPGraphicEQ, dapGraphicEQParameters, sizeof(DeviceDAPGraphicEQ));
|
|
}
|
|
}
|
|
virtual void setDAPBassEnhancer(DAPBassEnhancer *dapBassEnhancerParameters)
|
|
{
|
|
if (dapBassEnhancerParameters) {
|
|
memcpy(&DeviceDAPBassEnhancer, dapBassEnhancerParameters, sizeof(DeviceDAPBassEnhancer));
|
|
}
|
|
}
|
|
virtual void setDAPVirtualBass(DAPVirtualBass *dapVirtualBassParameters)
|
|
{
|
|
if (dapVirtualBassParameters) {
|
|
memcpy(&DeviceDAPVirtualBass, dapVirtualBassParameters, sizeof(DeviceDAPVirtualBass));
|
|
}
|
|
}
|
|
|
|
//DAP SWITCHES (content specific)
|
|
virtual void setDAPMISteering(DAPMISteering *dapMiSteeringParameters)
|
|
{
|
|
if (dapMiSteeringParameters) {
|
|
memcpy(&ContentDAPMISteering, dapMiSteeringParameters, sizeof(ContentDAPMISteering));
|
|
}
|
|
}
|
|
virtual void setDAPLeveler(DAPLeveler *dapLevelerParameters)
|
|
{
|
|
if (dapLevelerParameters) {
|
|
memcpy(&ContentDAPLeveler, dapLevelerParameters, sizeof(ContentDAPLeveler));
|
|
}
|
|
}
|
|
virtual void setDAPIEQ(DAPIEQ *dapIEQParameters)
|
|
{
|
|
if (dapIEQParameters) {
|
|
memcpy(&ContentDAPIEQ, dapIEQParameters, sizeof(ContentDAPIEQ));
|
|
}
|
|
}
|
|
virtual void setDAPDialogueEnhancer(DAPDialogueEnhancer *dapDialogueEnhancerParameters)
|
|
{
|
|
if (dapDialogueEnhancerParameters) {
|
|
memcpy(&ContentDAPDialogueEnhancer, dapDialogueEnhancerParameters, sizeof(ContentDAPDialogueEnhancer));
|
|
}
|
|
}
|
|
|
|
virtual void setAtmosLockFlag(bool flag)
|
|
{
|
|
mAtmosLock = flag;
|
|
ALOGI("%s() set mAtmosLock %d", __FUNCTION__, mAtmosLock);
|
|
}
|
|
|
|
virtual int getAtmosLockFlag(void)
|
|
{
|
|
return mAtmosLock;
|
|
}
|
|
|
|
/*OTT Processing Graph End*/
|
|
|
|
virtual void setLegacyDDPOut(bool isLegacyDDPOut)
|
|
{
|
|
mIsLegacyDDPOut = isLegacyDDPOut;
|
|
ALOGI("%s() mIsLegacyDDPOut %d\n", __FUNCTION__, mIsLegacyDDPOut);
|
|
}
|
|
|
|
virtual bool getLegacyDDPOut(void)
|
|
{
|
|
return mIsLegacyDDPOut;
|
|
}
|
|
|
|
virtual void setHDMIOutoutType(int HdmiOutputType)
|
|
{
|
|
mHdmiOutputType = HdmiOutputType;
|
|
ALOGI("%s() mHdmiOutputType %d\n", __FUNCTION__, mHdmiOutputType);
|
|
}
|
|
|
|
virtual void setDapOnly(int DapOnly)
|
|
{
|
|
mDapOnly = DapOnly;
|
|
ALOGI("%s() mDapOnly %d\n", __FUNCTION__, mDapOnly);
|
|
}
|
|
|
|
virtual void setHalContentProcess(int ContentProcessEnable)
|
|
{
|
|
mContentProcessEnable = ContentProcessEnable;
|
|
ALOGI("%s() mContentProcessEnable %d\n", __FUNCTION__, mContentProcessEnable);
|
|
}
|
|
|
|
virtual void setBitWidth(int bit_width)
|
|
{
|
|
mOutputBitDepth = bit_width;
|
|
ALOGI("%s() mOutputBitDepth %d\n", __FUNCTION__, bit_width);
|
|
}
|
|
|
|
virtual void setTVTuningFlag(bool tv_tuning_flag) {
|
|
mTVTuningFlag = tv_tuning_flag;
|
|
}
|
|
|
|
//*End||Add the APT to set the params*//
|
|
|
|
virtual void setVersion(int version)
|
|
{
|
|
mVersion = version;
|
|
ALOGI("%s() mVersion %d\n", __FUNCTION__, mVersion);
|
|
}
|
|
|
|
|
|
protected:
|
|
|
|
private:
|
|
int ms_get_int_array_from_str(char **p_csv_string, int num_el, int *p_vals);
|
|
int ms_get_int_from_str(char **p_csv_string, int *p_vals);
|
|
// DolbyMS12ConfigParams(const DolbyMS12ConfigParams&);
|
|
// DolbyMS12ConfigParams& operator = (const DolbyMS12ConfigParams&);
|
|
// static DolbyMS12ConfigParams *gInstance;
|
|
// static android::Mutex mLock;
|
|
// audio_devices_t mAudioSteamOutDevices;
|
|
int mParamNum;
|
|
int mRuntimeParamNum;
|
|
int mEncParamNum;
|
|
|
|
//dolby ms12 input
|
|
audio_output_flags_t mAudioOutFlags;
|
|
audio_format_t mAudioStreamOutFormat;
|
|
audio_channel_mask_t mDolbyMS12OutChannelMask[MS12_INPUT_MAX];
|
|
|
|
//dolby ms12 output
|
|
int mDolbyMS12OutConfig;
|
|
int mDolbyMS12OutSampleRate;
|
|
char **mConfigParams;//[MAX_ARGC][MAX_ARGV_STRING_LEN];
|
|
char **mRuntimeConfigParams;//[MAX_ARGC][MAX_ARGV_STRING_LEN];
|
|
char **mEncConfigParams;//[MAX_ARGC][MAX_ARGV_STRING_LEN];
|
|
|
|
|
|
// bool mMultiOutputFlag;
|
|
//bool mLowComplexityMode = false;
|
|
int mDRCBoost;
|
|
int mDRCCut;
|
|
int mDRCBoostStereo;
|
|
int mDRCCutStereo;
|
|
int mDAPInitMode;
|
|
int mDBGOut;//(default: none)
|
|
int mDRCModesOfDownmixedOutput;
|
|
int mDAPDRCMode;//for multi-ch and dap output[default is 0]
|
|
int mDownmixMode;//Lt/Rt[val=0, default] or Lo/Ro
|
|
int mEvaluationMode;//default is 0
|
|
int mLFEPresentInSystemSoundIn;//default is 0[means off]
|
|
int mDonwnmix71PCMto51;//default 0[means off]
|
|
int mLockingChannelModeENC;//0 default, auto; 1 locked as 5.1 channel mode.
|
|
int mRISCPrecisionFlag;//0 less&16bits for 16x32;1 high&32bits for 16x32
|
|
int mVerbosity;//here choose 0
|
|
int mOutputBitDepth;//here choose 16(bit)
|
|
int mSystemAPPAudioMixing;//0 off;1 on&default;
|
|
|
|
MixGain mSysPrimMixGain = {
|
|
.target = 0,
|
|
.duration = 0,
|
|
.shape = 0,
|
|
};//System sound mixer gain values for primary input (Input/AD mixer output)
|
|
MixGain mSysSyssMixGain = {
|
|
.target = 0,
|
|
.duration = 0,
|
|
.shape = 0,
|
|
};//System sound mixer gain values for System Sounds input
|
|
MixGain mSysAppsMixGain = {
|
|
.target = 0,
|
|
.duration = 0,
|
|
.shape = 0,
|
|
};//System sound mixer gain values for Application Sounds input
|
|
//DDPLUS SWITCHES
|
|
|
|
//PCM SWITCHES
|
|
int mCompressorProfile;//[pcm] Compressor profile
|
|
|
|
//DAP SWITCHES (device specific)
|
|
const char *mDAPTuningFile;
|
|
int mDAPGains = 0;//postgain (-2080...480, def: 0)
|
|
bool mDAPSurDecEnable = true;//DAP surround decoder enable flag (Default 1)
|
|
DAPSurroundVirtualizer DeviceDAPSurroundVirtualizer = {
|
|
.virtualizer_enable = 0,
|
|
.surround_boost = 96,
|
|
};
|
|
DAPGraphicEQ DeviceDAPGraphicEQ = {
|
|
.eq_enable = 0,
|
|
.eq_nb_bands = 10,
|
|
.eq_band_center = {32, 64, 125, 250, 500, 1000, 2000, 4000, 8000, 16000},
|
|
.eq_band_target = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
};
|
|
DAPBassEnhancer DeviceDAPBassEnhancer = {
|
|
.bass_enable = 0,
|
|
.bass_boost = 192,
|
|
.bass_cutoff = 200,
|
|
.bass_width = 16,
|
|
};
|
|
DAPVirtualBass DeviceDAPVirtualBass = {
|
|
.virtual_bass_mode = 0,
|
|
.virtual_bass_low_src_freq = 35,
|
|
.virtual_bass_high_src_freq = 160,
|
|
.virtual_bass_overall_gain = 0,
|
|
.virtual_bass_slope_gain = 0,
|
|
.virtual_bass_subgains = { -32, -144, -192},
|
|
.virtual_bass_low_mix_freq = 94,
|
|
.virtual_bass_high_mix_freq = 469,
|
|
};
|
|
|
|
//DAP SWITCHES (content specific)
|
|
DAPMISteering ContentDAPMISteering = {
|
|
.mi_enable = 0,
|
|
};
|
|
DAPLeveler ContentDAPLeveler = {
|
|
.leveler_enable = 0,
|
|
.leveler_amount = 4,
|
|
};
|
|
DAPIEQ ContentDAPIEQ = {
|
|
.ieq_enable = 0,
|
|
.ieq_amount = 10,
|
|
.ieq_nb_bands = 10,
|
|
.ieq_band_center = {32, 64, 125, 250, 500, 1000, 2000, 4000, 8000, 16000},
|
|
.ieq_band_target = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
};
|
|
DAPDialogueEnhancer ContentDAPDialogueEnhancer = {
|
|
.de_enable = 0,
|
|
.de_amount = 0,
|
|
};
|
|
|
|
bool mAtmosLock;
|
|
|
|
bool mIsLegacyDDPOut;
|
|
bool mTVTuningFlag;
|
|
bool mFullDAPDisable;
|
|
/*
|
|
DD/DD+ output is used for
|
|
0 = Full HDMI (default)
|
|
1 = HDMI ARC
|
|
2 = HDMI E-ARC
|
|
*/
|
|
int mHdmiOutputType;
|
|
int mDapOnly;
|
|
int mContentProcessEnable;
|
|
int mVersion;
|
|
int mFlapMaxRenderOutputs;
|
|
}; //class DolbyMS12ConfigParams
|
|
|
|
|
|
}//end of namespace android
|
|
#endif
|
|
|
|
#endif //end of _DOLBY_MS12_CONFIG_PARAMS_H_
|