开发环境:
内核版本:linux4.14.12
开发板:itopimx6ull

  1. 修改设备树(simple-card)widgets和routing录音没声音,播放可以
    这可能是因为录音的偏置routing没设置对,“MICB”。
sound {
		compatible = "simple-audio-card";
		//simple-audio-card,name = "mx6ul-wm8960";
		simple-audio-card,name = "MY_WM8960";
		simple-audio-card,format = "i2s";//音频数据传输格式
		simple-audio-card,mclk-fs = <1536>;//主控供给编解码芯片用的时钟
		//fsl,sai-asynchronous;
		simple-audio-card,bitclock-master = <&dailink_master>;//产生位时钟的模块
		simple-audio-card,frame-master = <&dailink_master>;//产生帧时钟的模块?
		//simple-audio-card,hp-det = <3 0>;
		simple-audio-card,hp-det-gpio = <&gpio5 4 GPIO_ACTIVE_LOW>;//耳机插入检测接口
		//simple-audio-card,mic-det-gpio = <&gpio5 4 GPIO_ACTIVE_LOW>;//麦克风插入检测接口
		simple-audio-card,widgets =
			"Microphone", "Mic Jack",//麦克风widgets 
			//"Line", "Line In",
			//"Line", "Line Out",
			"Speaker", "Speaker",//外放widgets 
			"Headphone", "Headphone Jack";//耳机widgets 
		//其中"HP_L""HP_R""SPK_LP""SPK_LN""SPK_RP""SPK_RN""MICB""LINPUT1"
		//在codec部分的代码里面找对应控件链路的名字
		simple-audio-card,routing =
			"Headphone Jack", "HP_L",//耳机左声道routing
			"Headphone Jack", "HP_R",//耳机右声道routing 
			"Speaker", "SPK_LP",//外放routing 
			"Speaker", "SPK_LN",//外放routing
			"Speaker", "SPK_RP",//外放routing
			"Speaker", "SPK_RN",//外放routing
			"Mic Jack","MICB",//麦克风偏置routing
			"LINPUT1", "Mic Jack";//麦克风输入routing
			//"LINPUT3", "Mic Jack",
			//"RINPUT1", "Mic Jack",
			//"RINPUT2", "Mic Jack";
		simple-audio-card,cpu {
			sound-dai = <&sai2>;//cpu端接口
		};
		dailink_master: simple-audio-card,codec {
			sound-dai = <&codec>;//编解码芯片端接口
			clocks = <&clks IMX6UL_CLK_SAI2>;
		};
	};

&sai2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_sai2>;
	assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>,
			  <&clks IMX6UL_CLK_SAI2>;
	assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;
	//assigned-clock-rates = <0>, <12288000>;
	assigned-clock-rates = <0>, <24000000>;
	fsl,sai-mclk-direction-output;//mclk由sai2提供
	status = "okay";
};

codec: wm8960@1a {
		#sound-dai-cells = <0>;
		compatible = "wlf,wm8960";
		reg = <0x1a>;
		wlf,shared-lrclk;
	};
  1. 修改reg_default寄存器的值没有更新到wm8960中
    在设置耳机检测功能时发现修改reg_default寄存器中对应的值并没有写到wm8960芯片里面,可能在初始化时选择性写入吧。解决办法,使用代码直接更新相应的寄存器。
//在codec部分,wm8960_i2c_probe中加入代码,打开对应的设置
//add by mhq
	regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 3<<5, 3<<5);
	regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 3<<2, 3<<2);
	regmap_update_bits(wm8960->regmap, WM8960_ADDCTL1, 3, 3);

	//gpio1
	regmap_update_bits(wm8960->regmap, WM8960_IFACE2, 1<<6, 1<<6);
	regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 7<<4, 3<<4);

	//headphone volmue
	regmap_update_bits(wm8960->regmap, WM8960_LOUT1, 0x7f, 90);
	regmap_update_bits(wm8960->regmap, WM8960_ROUT1, 0x7f, 90);

	//headphone vol
	
	
	regmap_update_bits(wm8960->regmap, WM8960_LOUTMIX, 0x100, 0x100);
	regmap_update_bits(wm8960->regmap, WM8960_ROUTMIX, 0x100, 0x100);
	//add end
  1. ASoC: DAPM unknown pin Headphones
    由于在sound/soc/generic/simple-card.c中,asoc_simple_card_init_jack函数中设置的pin_name是Headphones,和routing中的Headphone Jack名字不匹配,将pin_name名字改为Headphone Jack就可以解决。
    在sound目录下搜索grep “unknown\ pin” -nr,会发现“ASoC: DAPM unknown pin Headphones”该错误提示是在sound/soc/soc-dapm.c中的snd_soc_dapm_set_pin函数中产生;
    snd_soc_dapm_set_pin函数中的dapm_find_widget函数会通过名字等查找匹配的weight;
Logo

更多推荐