MTK 平台如何配置喇叭和听筒二合一


[DESCRIPTION]

有客户会使用听筒喇叭二合一的方式来节省成本,因此需要进行相关的配置

[SOLUTION]

一. 开启通路

1. ProjectConfig.mk

MTK_2IN1_SPK_SUPPORT = yes

2. audio_device.xml
two_in_one_speaker_output下面的配置修改成和speaker打开时的配置一致
例如:
使用外部PA,接在lineout上,打开speaker的时候需要同时调用Speaker_Amp_Switch和Ext_Speaker_Amp_Switch这两个kctl,打开MTK_2IN1_SPK_SUPPORT这个宏之后,打开听筒的时候也应该调用这两个kctl

    <!-- 2-in-1 speaker output-->
    <path name="two_in_one_speaker_output" value="turnon">
        <kctl name="Speaker_Amp_Switch" value="On" />
        <kctl name="Audio_Speaker_class_Switch" value="CLASSAB" />
    </path>
    <path name="two_in_one_speaker_output" value="turnoff">
        <kctl name="Audio_Speaker_class_Switch" value="RECEIVER" />
        <kctl name="Speaker_Amp_Switch" value="Off" />

改为

    <!-- 2-in-1 speaker output-->
    <path name="two_in_one_speaker_output" value="turnon">
	    <kctl name="Speaker_Amp_Switch" value="On" />
	    <kctl name="Ext_Speaker_Amp_Switch" value="On" />
    </path>
    <path name="two_in_one_speaker_output" value="turnoff">
            <kctl name="Ext_Speaker_Amp_Switch" value="Off" />
	    <kctl name="Speaker_Amp_Switch" value="Off" />

二. 外部PA的模式切换

通常听筒模式和喇叭模式的声音大小是不一样的,所以需要调整喇叭模式和听筒模式的外部PA的工作的mode

1./vendor/mediatek/proprietary/custom/proj/hal/audioflinger/audio/audio_custom_exp.h 增加

 
 #define HAVING_RCV_SPK_SWITCH

2./vendor/mediatek/proprietary/hardware/audio/common/V3/aud_drv/AudioALSAHardwareResourceManager.cpp

status_t AudioALSAHardwareResourceManager::OpenReceiverPath(const uint32_t SampleRate __unused) {
//AudioALSACodecDeviceOutReceiverPMIC::getInstance()->open();
    IsAudioSupportFeature(AUDIO_SUPPORT_2IN1_SPEAKER)) {
    mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_2IN1_SPEAKER);
} else {
    mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_RECEIVER);
}
   #ifdef HAVING_RCV_SPK_SWITCH
     AudioALSACodecDeviceOutReceiverSpeakerSwitch::getInstance()->open();
   #endif

    return NO_ERROR;
   }

修改成:

status_t AudioALSAHardwareResourceManager::OpenReceiverPath(const uint32_t SampleRate __unused) {
    #ifdef HAVING_RCV_SPK_SWITCH
    AudioALSACodecDeviceOutReceiverSpeakerSwitch::getInstance()->open();
    #endif
    //AudioALSACodecDeviceOutReceiverPMIC::getInstance()->open();
    if (IsAudioSupportFeature(AUDIO_SUPPORT_2IN1_SPEAKER)) {
    mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_2IN1_SPEAKER);
} 
  else {
   mDeviceConfigManager->ApplyDeviceTurnonSequenceByName(AUDIO_DEVICE_RECEIVER);
 }

3. /kernel-4.4/sound/soc/mediatek/codec/mt6357/mtk-soc-codec-6357.c

static void Ext_Speaker_Amp_Change(bool enable)
{
enable的时候加一下判断,receiver有开,就设置mode 8,如果没有开就设置mode 3
disable的时候也是,receiver有开,就按mode 8 去关闭,如果没有,就按mode 3去关闭
例子如下
//modify here 
if (pin_extspkamp != 54)
if(mCodec_data->mAudio_Ana_DevicePower[AUDIO_ANALOG_DEVICE_RECEIVER_SPEAKER_SWITCH] == true) 
AudDrv_GPIO_EXTAMP_Select(false, 8);
else
AudDrv_GPIO_EXTAMP_Select(false, 3); 
else
if(mCodec_data->mAudio_Ana_DevicePower[AUDIO_ANALOG_DEVICE_RECEIVER_SPEAKER_SWITCH] == true) 
AudDrv_GPIO_EXTAMP2_Select(false, 8);
else
AudDrv_GPIO_EXTAMP2_Select(false, 3);
////////
#endif 
......

后续mode的改动也按照上述方式修改

}

三. 正确加载听筒的参数,需要如下修改/device/mediatek/proj/audio_param/VolumeGainMap_AudioParam.xml
RCV_NO_ANA对应的param_id下面的

<Param name="dl_analog_type" value="0"/>

改为

<Param name="dl_analog_type" value="3"/>

uboot 编译出现 Error: You must add new CONFIG options using Kconfig 解决方法


[现象]

UBoot 编译时出现:

Error: You must add new CONFIG options using Kconfig The following new ad-hoc CONFIG options were detected:

[方法] 修改其中一个即可

1. 增加对应的值到

u-boot\scripts\config_whitelist.txt

2. 注释掉顶层 Makefile 中下面几句:

quiet_cmd_cfgcheck = CFGCHK  $2
cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
		$(srctree)/scripts/config_whitelist.txt $(srctree)

改成:

#quiet_cmd_cfgcheck = CFGCHK  $2
#cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
#		$(srctree)/scripts/config_whitelist.txt $(srctree)

3. 修改 Error 为 Warning 防止编译中断

diff --git a/scripts/check-config.sh b/scripts/check-config.sh
index 6618dfb..9d2cfc6 100755
--- a/scripts/check-config.sh
+++ b/scripts/check-config.sh
@@ -37,14 +37,13 @@  cat `find ${srctree} -name "Kconfig*"` |sed -n \
 	-e 's/^menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' |sort |uniq > ${ok}
 comm -23 ${suspects} ${ok} >${new_adhoc}
 if [ -s ${new_adhoc} ]; then
-	echo "Error: You must add new CONFIG options using Kconfig"
+	echo "Warning: You must add new CONFIG options using Kconfig"
 	echo "The following new ad-hoc CONFIG options were detected:"
 	cat ${new_adhoc}
 	echo
 	echo "Please add these via Kconfig instead. Find a suitable Kconfig"
 	echo "file and add a 'config' or 'menuconfig' option."
 	# Don't delete the temporary files in case they are useful
-	exit 1
 else
 	rm ${suspects} ${ok} ${new_adhoc}
 fi

打开 php-fpm 错误日志完整记录修改方法


php-fpm的默认日志输出比较少,且nginx中也没有想要日志,因此要做如下修改才能保存完整的记录,方便调试:

[方法]

1. 修改php-fpm.conf中的配置,如果没有请增加:

[global]
catch_workers_output = yes
[www]
error_log = /var/log/php-fpm.log

2. 修改php.ini中配置,没有则增加

log_errors = On
error_log = "/var/log/php-fpm_error.log"
error_reporting=E_ALL&~E_NOTICE

3. 重启php-fpm 即可看到对应的log

继续阅读“打开 php-fpm 错误日志完整记录修改方法”

mysql5.7 配合 php5.6 时出现Call to undefined function mysql_connect 解决方法


[现象]

mysql5.7 配合 php5.6 时出现如下mysql连接错误:

[pool www] child 21312 said into stderr: “NOTICE: PHP message: PHP Fatal error: Call to undefined function mysql_connect()

继续阅读“mysql5.7 配合 php5.6 时出现Call to undefined function mysql_connect 解决方法”

mysql 外部访问设置


1. 增加或者修改用户root的host为%,给与所有IP有访问权限。

mysql>use mysql; 

mysql>update user set host = ‘%’ where user =’root’; 
或者:
mysql>grant all privileges  on *.* to root@'%' identified by "password";

mysql>flush privileges; 
mysql>quit

继续阅读“mysql 外部访问设置”