audio: Fixed loudness test fail. [1/1]
PD#SWPL-197702
Problem:
Need set tuner_type in audiohal.
Solution:
1.Set tuner_type in audiohal;
2.Adjust the pre-attenuation value for ms12 input.
Verify:
Alpine.
Change-Id: I0c41629ddc384b48c361fe2ff49e5dad88987f56
Signed-off-by: yuliang.hu <yuliang.hu@amlogic.com>
diff --git a/audio_hal/audio_hw.c b/audio_hal/audio_hw.c
index 6ceaf52..c567ad6 100644
--- a/audio_hal/audio_hw.c
+++ b/audio_hal/audio_hw.c
@@ -298,6 +298,7 @@
size_t* mic_count);
static int aml_audio_focus(struct aml_audio_device *adev, bool on);
+static int adev_get_dvb_standards();
#define AML_PARSER_DEBUG "vendor.media.audio.parser.debug"
static int aml_audio_parser_process_wrapper(struct audio_stream_out *stream,
@@ -4228,6 +4229,20 @@
}
//add for roku
+ ret = str_parms_get_str(parms,"tuner_type", value , sizeof(value));
+ if (ret >= 0) {
+ AM_LOGI("tuner_type=%s", value);
+ setenv("ro_vendor_platform_digitaltv_standards", value, 1);
+ adev->dvb_standards = adev_get_dvb_standards();
+ /* If ms12 has been initialized, dvb_standards needs to be re-initialized to take effect */
+ if (ms12->dolby_ms12_init_flags) {
+ adev_ms12_cleanup(&adev->hw_device);
+ adev_ms12_prepare(&adev->hw_device);
+ AM_LOGI(" dvb_standards update, need reset ms12");
+ }
+ goto exit;
+ }
+
ret = str_parms_get_str(parms, "sink_atoms_capability", value, sizeof(value));
if (ret >= 0) {
struct aml_arc_hdmi_desc *hdmi_desc = get_arc_hdmi_cap(adev);
@@ -8262,6 +8277,7 @@
dprintf(fd, "\n");
dprintf(fd, "[AML_HAL] hdmi_format : %10d | active_outport : %s | active_inport: %s\n",
aml_dev->hdmi_format, outputPort2Str(aml_dev->active_outport), inputPort2Str(get_active_inport(aml_dev)));
+ dprintf(fd, "[AML_HAL] dvb_standards : %d\n", aml_dev->dvb_standards);
dprintf(fd, "[AML_HAL] injection : %d\n", aml_dev->injection_enable);
pthread_mutex_lock(&aml_dev->cap_handle_lock);
dprintf(fd, "[AML_HAL] capture enable : %d\n", aml_dev->capture_handle ? 1 :0);
@@ -8597,7 +8613,7 @@
}
}
- AM_LOGI("dtv tuner_type: %d", dtv_type);
+ AM_LOGI("dtv tuner_type: %d(0:DVB 1:ATSC)", dtv_type);
return dtv_type;
}
@@ -8915,7 +8931,6 @@
adev->hw_device.get_microphones = adev_get_microphones;
adev->hw_device.get_audio_port = adev_get_audio_port;
adev->hw_device.dump = adev_dump;
- adev->dvb_standards = adev_get_dvb_standards();
adev->hdmi_format = AUTO;
adev->is_hdmi_arc_interact_done = false;
adev->is_netflix_hide = false;
@@ -8986,6 +9001,7 @@
ALOGE("%s() Audio Config file parsing error\n",__FUNCTION__);
} else {
audio_hal_property_list_loading();
+ adev->dvb_standards = adev_get_dvb_standards();
}
if (0 != aml_audio_avsync_parser()) {
ALOGE("%s() Audio Config file parsing error\n",__FUNCTION__);
diff --git a/audio_hal/audio_hw_ms12_v2.c b/audio_hal/audio_hw_ms12_v2.c
index f614555..af2a967 100644
--- a/audio_hal/audio_hw_ms12_v2.c
+++ b/audio_hal/audio_hw_ms12_v2.c
@@ -139,7 +139,8 @@
#define LOUDNESS_PROCESS_VALUES_DB_EUDVB (8.0)
#define LOUDNESS_PROCESS_VALUES_DB (7.0)
-#define PRE_ATTENUATION_VALUES_DB (-8.0)
+#define PRE_ATTENUATION_VALUES_DB_EUDVB (-8.0)
+#define PRE_ATTENUATION_VALUES_DB (-7.0)
/*this enum should be same with ms12 lib*/
typedef enum {
@@ -1486,11 +1487,12 @@
struct aml_audio_device *adev = aml_out->dev;
int channels = audio_channel_count_from_out_mask(aml_out->hal_channel_mask);
- aml_out->drc_mode_volume = DbToAmpl(PRE_ATTENUATION_VALUES_DB);
+ /*DVB pre-attenuate -8db, ATSC and DTMB pre-attenuate -7db*/
+ aml_out->drc_mode_volume = DbToAmpl(adev->dvb_standards == DTV_STANDARDS_EUDVB ? PRE_ATTENUATION_VALUES_DB_EUDVB : PRE_ATTENUATION_VALUES_DB);
apply_volume_fade(aml_out->last_drc_mode_volume, aml_out->drc_mode_volume, buffer, sizeof(uint16_t), channels, bytes);
if (aml_out->last_drc_mode_volume != aml_out->drc_mode_volume) {
- ALOGI("[%s:%d](Attenuate 8dB) aml_out=%p cur_volume=%f last_volume=%f channels=%d bytes=%zu",
- __func__, __LINE__, aml_out, aml_out->drc_mode_volume , aml_out->last_drc_mode_volume, channels, bytes);
+ AM_LOGI("dvb_standards:%d(Attenuate -7db or -8dB) aml_out=%p cur_volume=%f last_volume=%f channels=%d bytes=%zu",
+ adev->dvb_standards, aml_out, aml_out->drc_mode_volume , aml_out->last_drc_mode_volume, channels, bytes);
aml_out->last_drc_mode_volume = aml_out->drc_mode_volume;
}
}