M module-bsp/board/rt1051/bsp/audio/CodecMAX98090.cpp => module-bsp/board/rt1051/bsp/audio/CodecMAX98090.cpp +32 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "CodecMAX98090.hpp"
@@ 191,6 191,7 @@ CodecRetCode CodecMAX98090::Start(const CodecParams ¶m)
case bsp::AudioDevice::InputPath::Microphone: {
max98090_reg_input_to_record_quick_t q_input_setup = {0};
max98090_reg_digmic_enable_t digena = {0};
+ max98090_reg_digmic_conf_t digconf = {0};
// Enable left and right digital mic interface
digena.digmicl = 1;
@@ 198,9 199,37 @@ CodecRetCode CodecMAX98090::Start(const CodecParams ¶m)
// Harman Kardon dig microphones specify valid clock range as 1.024MHz - 4.8MHz, typical ~2.4MHz
digena.dmicclk = 3; // fDMC = fPCLK/5 - > fPCLK=12.288MHz fDMC = 2.458MHz
+ // Table 17 from datasheet
+ digconf.dmicfreq = 0;
+ switch (currentParams.GetSampleRateVal()) {
+ case 8000:
+ digconf.dmiccomp =
+ static_cast<uint8_t>(CodecParamsMAX98090::DigitalMicrophoneCompensationFilter::DMIC_COMP_7);
+ break;
+ case 16000:
+ digconf.dmiccomp =
+ static_cast<uint8_t>(CodecParamsMAX98090::DigitalMicrophoneCompensationFilter::DMIC_COMP_8);
+ break;
+ case 32000:
+ case 44100:
+ case 48000:
+ digconf.dmiccomp =
+ static_cast<uint8_t>(CodecParamsMAX98090::DigitalMicrophoneCompensationFilter::DMIC_COMP_6);
+ break;
+ case 96000:
+ case 0:
+ default:
+ digconf.dmiccomp =
+ static_cast<uint8_t>(CodecParamsMAX98090::DigitalMicrophoneCompensationFilter::DMIC_COMP_6);
+ break;
+ }
+
i2cAddr.subAddress = MAX98090_REG_DIG_MIC_ENABLE;
i2c->Write(i2cAddr, (uint8_t *)&digena, 1);
+ i2cAddr.subAddress = MAX98090_REG_DIG_MIC_CONF;
+ i2c->Write(i2cAddr, (uint8_t *)&digconf, 1);
+
q_input_setup.in12sab = 1;
i2cAddr.subAddress = MAX98090_REG_LINE_INPUT_TO_RECORD_QUICK;
i2c->Write(i2cAddr, (uint8_t *)&q_input_setup, 1);
@@ 382,7 411,7 @@ CodecRetCode CodecMAX98090::SetInputGain(const float gain)
}
max98090_reg_lrec_dig_gain_t lgain = {0};
- lgain.avl = 0xF; // fine gain - 0xF: -12dB
+ lgain.avl = static_cast<uint8_t>(CodecParamsMAX98090::RecordPathDigitalFineGain::Gain_p3dB); // fine gain
lgain.avlg = gainToSet * 0.7; // coarse gain (0.7 used as scaling factor)
i2cAddr.subAddress = MAX98090_REG_LREC_DIG_GAIN;
@@ 390,7 419,7 @@ CodecRetCode CodecMAX98090::SetInputGain(const float gain)
// coarse gain - 18dB, fine gain - 0dB
max98090_reg_rrec_dig_gain_t rgain = {0};
- rgain.avr = 0xF; // fine gain - 0xF: -12dB
+ rgain.avr = static_cast<uint8_t>(CodecParamsMAX98090::RecordPathDigitalFineGain::Gain_p3dB); // fine gain
rgain.avrg = gainToSet * 0.7; // coarse gain (0.7 used as scaling factor)
i2cAddr.subAddress = MAX98090_REG_RREC_DIG_GAIN;
M module-bsp/board/rt1051/bsp/audio/CodecMAX98090.hpp => module-bsp/board/rt1051/bsp/audio/CodecMAX98090.hpp +28 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#ifndef PUREPHONE_CODECMAX98090_HPP
@@ 40,6 40,33 @@ class CodecParamsMAX98090 : public CodecParams
Stereoq
};
+ enum class DigitalMicrophoneCompensationFilter
+ {
+ DMIC_COMP_6 = 6,
+ DMIC_COMP_7 = 7,
+ DMIC_COMP_8 = 8
+ };
+
+ enum class RecordPathDigitalFineGain
+ {
+ Gain_p3dB = 0,
+ Gain_p2dB,
+ Gain_p1dB,
+ Gain_0dB,
+ Gain_n1dB0,
+ Gain_n2dB,
+ Gain_n3dB,
+ Gain_n4dB,
+ Gain_n5dB,
+ Gain_n6dB,
+ Gain_n7dB,
+ Gain_n8dB,
+ Gain_n9dB,
+ Gain_n10dB,
+ Gain_n11dB,
+ Gain_n12dB
+ };
+
static SampleRate ValToSampleRate(uint32_t rate)
{
switch (rate) {
M module-cellular/Modem/TS0710/TS0710.cpp => module-cellular/Modem/TS0710/TS0710.cpp +4 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "TS0710.h"
@@ 271,7 271,9 @@ TS0710::ConfState TS0710::AudioConfProcedure()
if (!ret) {
return ConfState ::Failure;
}
- else if (ret.response[0].compare("+QDAI: 1,0,0,5,0,1,1,1") == 0) {
+ else if (ret.response[0].compare("+QDAI: 1,0,0,3,0,1,1,1") == 0) {
+ parser->cmd(at::AT::CLVL);
+ parser->cmd(at::AT::QMIC);
return ConfState ::Success;
}
else {
M module-cellular/at/Commands.hpp => module-cellular/at/Commands.hpp +8 -2
@@ 129,6 129,9 @@ namespace at
QIACT, /// Activate a PDP Context
QIDEACT, /// Deactivate a PDP Context
CSCA, /// check SMS Center
+ QRXGAIN, /// Set Downlink Gains of RX
+ CLVL, /// Loudspeaker Volume Level Selection
+ QMIC, /// Set Uplink Gains of MIC
};
// below timeouts are defined in Quectel_EC25&EC21_AT_Commands_Manual_V1.3.pdf
@@ 158,7 161,7 @@ namespace at
{AT::SMS_GSM, {"AT+CSCS=\"GSM\""}},
{AT::QSCLK_ON, {"AT+QSCLK=1", 3000ms}},
{AT::QDAI, {"AT+QDAI?"}},
- {AT::QDAI_INIT, {"AT+QDAI=1,0,0,5,0,1"}},
+ {AT::QDAI_INIT, {"AT+QDAI=1,0,0,3,0,1,1,1"}},
{AT::SET_URC_CHANNEL, {"AT+QCFG=\"cmux/urcport\",2", default_doc_timeout}},
{AT::CSQ, {"AT+CSQ", default_doc_timeout}},
{AT::CLCC, {"AT+CLCC", default_doc_timeout}},
@@ 228,7 231,10 @@ namespace at
{AT::CSSN, {"AT+CSSN=\"", default_doc_timeout}},
{AT::QICSGP, {"AT+QICSGP", default_timeout}},
{AT::QIACT, {"AT+QIACT", 150000ms}},
- {AT::QIDEACT, {"AT+QIDEACT", 40000ms}}};
+ {AT::QIDEACT, {"AT+QIDEACT", 40000ms}},
+ {AT::QRXGAIN, {"AT+QRXGAIN=65535", default_timeout}},
+ {AT::CLVL, {"AT+CLVL=3", default_timeout}},
+ {AT::QMIC, {"AT+QMIC=15000,15000", default_timeout}}};
if (fact.count(at) != 0u) {
return fact.at(at);
M module-services/service-audio/ServiceAudio.cpp => module-services/service-audio/ServiceAudio.cpp +3 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "service-audio/AudioMessage.hpp"
@@ 66,8 66,8 @@ sys::ReturnCodes ServiceAudio::InitHandler()
// ROUTING
{dbPath(Setting::Gain, PlaybackType::None, Profile::Type::RoutingBluetoothHSP), "20"},
- {dbPath(Setting::Gain, PlaybackType::None, Profile::Type::RoutingEarspeaker), "0"},
- {dbPath(Setting::Gain, PlaybackType::None, Profile::Type::RoutingLoudspeaker), "20"},
+ {dbPath(Setting::Gain, PlaybackType::None, Profile::Type::RoutingEarspeaker), "3"},
+ {dbPath(Setting::Gain, PlaybackType::None, Profile::Type::RoutingLoudspeaker), "10"},
{dbPath(Setting::Gain, PlaybackType::None, Profile::Type::RoutingHeadphones), "0"},
{dbPath(Setting::Volume, PlaybackType::None, Profile::Type::RoutingBluetoothHSP), defaultVolumeHigh},