欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

msm8953 audio部分的EAR和Speaker输出的声音配置

程序员文章站 2022-07-14 15:50:32
...

1、原理
msm8953 audio部分的EAR和Speaker输出的声音配置
msm8953 audio部分的EAR和Speaker输出的声音配置
msm8953 audio部分的EAR和Speaker输出的声音配置
2、代码移植:
kernel\msm-4.9\arch\arm64\boot\dts\GM620S\msm8953-audio.dtsi

#include "msm-audio-lpass.dtsi"
#include "msm8953-wsa881x.dtsi"

&msm_audio_ion {
	iommus = <&apps_iommu 0x2401 0x0>;
	qcom,smmu-sid-mask = /bits/ 64 <0xf>;
};

&soc {
	qcom,msm-audio-apr {
		compatible = "qcom,msm-audio-apr";
		msm_audio_apr_dummy {
			compatible = "qcom,msm-audio-apr-dummy";
		};
	};

	qcom,aaa@qq.com {
		compatible = "qcom,avtimer";
		reg = <0x0c0a300c 0x4>,
			<0x0c0a3010 0x4>;
		reg-names = "avtimer_lsb_addr", "avtimer_msb_addr";
		qcom,clk-div = <27>;
	};

	int_codec: sound {
		status = "okay";
		compatible = "qcom,msm8952-audio-codec";
		qcom,model = "msm8953-snd-card-mtp";
		reg = <0xc051000 0x4>,
			<0xc051004 0x4>,
			<0xc055000 0x4>,
			<0xc052000 0x4>;
		reg-names = "csr_gp_io_mux_mic_ctl",
			"csr_gp_io_mux_spkr_ctl",
			"csr_gp_io_lpaif_pri_pcm_pri_mode_muxsel",
			"csr_gp_io_mux_quin_ctl";

		qcom,msm-ext-pa = "primary";
		qcom,msm-mclk-freq = <9600000>;
		qcom,msm-mbhc-hphl-swh = <1>; //kangting modify
		qcom,msm-mbhc-gnd-swh = <0>;
		qcom,msm-hs-micbias-type = "internal";
		qcom,msm-micbias1-ext-cap;

		qcom,audio-routing =
				"RX_BIAS", "MCLK",
				"SPK_RX_BIAS", "MCLK",
				"INT_LDO_H", "MCLK",
				"RX_I2S_CLK", "MCLK",
				"TX_I2S_CLK", "MCLK",
				//"MIC BIAS External", "Handset Mic", //kangting modify
				//"MIC BIAS External2", "Headset Mic",
				//"MIC BIAS External", "Secondary Mic",
				"MIC BIAS Internal1", "Handset Mic",
				"MIC BIAS Internal2", "Headset Mic",
				"MIC BIAS Internal1", "Secondary Mic",
				//"AMIC1", "MIC BIAS External",
				//"AMIC2", "MIC BIAS External2",
				//"AMIC3", "MIC BIAS External",
				"AMIC1", "MIC BIAS Internal1",
				"AMIC2", "MIC BIAS Internal2",
				"AMIC3", "MIC BIAS Internal1",
				"ADC1_IN", "ADC1_OUT",
				"ADC2_IN", "ADC2_OUT",
				"ADC3_IN", "ADC3_OUT",
				"PDM_IN_RX1", "PDM_OUT_RX1",
				"PDM_IN_RX2", "PDM_OUT_RX2",
				"PDM_IN_RX3", "PDM_OUT_RX3",
				"WSA_SPK OUT", "VDD_WSA_SWITCH",
				"SpkrMono WSA_IN", "WSA_SPK OUT";

		//qcom,cdc-us-euro-gpios = <&tlmm 63 0>;//kangting modify
		qcom,cdc-us-eu-gpios = <&cdc_us_euro_sw>;
		qcom,cdc-comp-gpios = <&cdc_comp_gpios>;
		qcom,pri-mi2s-gpios = <&cdc_pri_mi2s_gpios>;
		qcom,quin-mi2s-gpios = <&cdc_quin_mi2s_gpios>;

		asoc-platform = <&pcm0>, <&pcm1>, <&pcm2>, <&voip>, <&voice>,
				<&loopback>, <&compress>, <&hostless>,
				<&afe>, <&lsm>, <&routing>, <&pcm_noirq>;
		asoc-platform-names = "msm-pcm-dsp.0", "msm-pcm-dsp.1",
				"msm-pcm-dsp.2", "msm-voip-dsp",
				"msm-pcm-voice", "msm-pcm-loopback",
				"msm-compress-dsp", "msm-pcm-hostless",
				"msm-pcm-afe", "msm-lsm-client",
				"msm-pcm-routing", "msm-pcm-dsp-noirq";
		asoc-cpu = <&dai_pri_auxpcm>,
			<&dai_mi2s0>, <&dai_mi2s1>,
			<&dai_mi2s2>, <&dai_mi2s3>,
			<&dai_mi2s4>, <&dai_mi2s5>,
			<&sb_0_rx>, <&sb_0_tx>, <&sb_1_rx>, <&sb_1_tx>,
			<&sb_3_rx>, <&sb_3_tx>, <&sb_4_rx>, <&sb_4_tx>,
			<&bt_sco_rx>, <&bt_sco_tx>,
			<&int_fm_rx>, <&int_fm_tx>,
			<&afe_pcm_rx>, <&afe_pcm_tx>,
			<&afe_proxy_rx>, <&afe_proxy_tx>,
			<&incall_record_rx>, <&incall_record_tx>,
			<&incall_music_rx>, <&incall_music_2_rx>;

		asoc-cpu-names = "msm-dai-q6-auxpcm.1",
				"msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1",
				"msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3",
				"msm-dai-q6-mi2s.4", "msm-dai-q6-mi2s.6",
				"msm-dai-q6-dev.16384", "msmdai-q6-dev.16385",
				"msm-dai-q6-dev.16386", "msm-dai-q6-dev.16387",
				"msm-dai-q6-dev.16390", "msm-dai-q6-dev.16391",
				"msm-dai-q6-dev.16392", "msm-dai-q6-dev.16393",
				"msm-dai-q6-dev.12288", "msm-dai-q6-dev.12289",
				"msm-dai-q6-dev.12292", "msm-dai-q6-dev.12293",
				"msm-dai-q6-dev.224", "msm-dai-q6-dev.225",
				"msm-dai-q6-dev.241", "msm-dai-q6-dev.240",
				"msm-dai-q6-dev.32771", "msm-dai-q6-dev.32772",
				"msm-dai-q6-dev.32773", "msm-dai-q6-dev.32770";

		asoc-codec = <&stub_codec>, <&msm_digital_codec>,
				<&pmic_analog_codec>;
		asoc-codec-names = "msm-stub-codec.1", "msm-dig-codec",
					"analog-codec";
		asoc-wsa-codec-names = "wsa881x-i2c-codec.2-000f";
		asoc-wsa-codec-prefixes = "SpkrMono";
		msm-vdd-wsa-switch-supply = <&pm8953_l5>;
		qcom,msm-vdd-wsa-switch-voltage = <1800000>;
		qcom,msm-vdd-wsa-switch-current = <10000>;
	};

	cdc_us_euro_sw: msm_cdc_pinctrl_us_euro_sw {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&cross_conn_det_act>;
		pinctrl-1 = <&cross_conn_det_sus>;
	};

	cdc_comp_gpios: cdc_comp_pinctrl {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&cdc_pdm_comp_lines_act>;
		pinctrl-1 = <&cdc_pdm_comp_lines_sus>;
	};

	cdc_pri_mi2s_gpios: msm_cdc_pinctrl_pri {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&cdc_pdm_lines_act &cdc_pdm_lines_2_act>;
		pinctrl-1 = <&cdc_pdm_lines_sus &cdc_pdm_lines_2_sus>;
	};

	cdc_quin_mi2s_gpios: msm_cdc_pinctrl_quin {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&pri_tlmm_lines_act &pri_tlmm_ws_act>;
		pinctrl-1 = <&pri_tlmm_lines_sus &pri_tlmm_ws_sus>;
	};


	aaa@qq.com78b6000 {
		status = "okay";
		#address-cells = <1>;
		#size-cells = <0>;
		wsa881x_i2c_f: wsa881x-i2c-aaa@qq.com {
			status = "okay";
			compatible = "qcom,wsa881x-i2c-codec";
			reg = <0x0f>;
			qcom,wsa-analog-vi-gpio = <&wsa881x_analog_vi_gpio>;
			qcom,wsa-analog-clk-gpio = <&wsa881x_analog_clk_gpio>;
			qcom,wsa-analog-reset-gpio =
				<&wsa881x_analog_reset_gpio>;
		};
		wsa881x_i2c_45: wsa881x-i2c-aaa@qq.com45 {
			status = "okay";
			compatible = "qcom,wsa881x-i2c-codec";
			reg = <0x45>;
		};
	};

	wsa881x_analog_vi_gpio: wsa881x_analog_vi_pctrl {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&wsa_vi_on>;
		pinctrl-1 = <&wsa_vi_off>;
	};
	wsa881x_analog_clk_gpio: wsa881x_analog_clk_pctrl {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&wsa_clk_on>;
		pinctrl-1 = <&wsa_clk_off>;
	};
	wsa881x_analog_reset_gpio: wsa881x_analog_reset_pctrl {
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&wsa_reset_on>;
		pinctrl-1 = <&wsa_reset_off>;
	};

	ext_codec: sound-9335 {
		status = "disabled";
		compatible = "qcom,msm8952-audio-slim-codec";
		qcom,model = "msm8953-tasha-snd-card";

		reg = <0xc051000 0x4>,
			<0xc051004 0x4>,
			<0xc055000 0x4>,
			<0xc052000 0x4>;
		reg-names = "csr_gp_io_mux_mic_ctl",
			"csr_gp_io_mux_spkr_ctl",
			"csr_gp_io_lpaif_pri_pcm_pri_mode_muxsel",
			"csr_gp_io_mux_quin_ctl";

		qcom,audio-routing =
			"AIF4 VI", "MCLK",
			"AIF4 VI", "MICBIAS_REGULATOR",
			"RX_BIAS", "MCLK",
			"MADINPUT", "MCLK",
			"AIF4 MAD", "MICBIAS_REGULATOR",
			"AMIC2", "MIC BIAS2",
			"MIC BIAS2", "Headset Mic",
			"AMIC3", "MIC BIAS2",
			"MIC BIAS2", "ANCRight Headset Mic",
			"AMIC4", "MIC BIAS2",
			"MIC BIAS2", "ANCLeft Headset Mic",
			"AMIC5", "MIC BIAS3",
			"MIC BIAS3", "Handset Mic",
			"AMIC6", "MIC BIAS4",
			"MIC BIAS4", "Analog Mic6",
			"DMIC0", "MIC BIAS1",
			"MIC BIAS1", "Digital Mic0",
			"DMIC1", "MIC BIAS1",
			"MIC BIAS1", "Digital Mic1",
			"DMIC2", "MIC BIAS3",
			"MIC BIAS3", "Digital Mic2",
			"DMIC3", "MIC BIAS3",
			"MIC BIAS3", "Digital Mic3",
			"DMIC4", "MIC BIAS4",
			"MIC BIAS4", "Digital Mic4",
			"DMIC5", "MIC BIAS4",
			"MIC BIAS4", "Digital Mic5",
			"MIC BIAS1", "MICBIAS_REGULATOR",
			"MIC BIAS2", "MICBIAS_REGULATOR",
			"MIC BIAS3", "MICBIAS_REGULATOR",
			"MIC BIAS4", "MICBIAS_REGULATOR",
			"SpkrLeft IN", "SPK1 OUT",
			"SpkrRight IN", "SPK2 OUT";

		qcom,tasha-mclk-clk-freq = <9600000>;
		qcom,cdc-us-euro-gpios = <&tlmm 63 0>;
		qcom,msm-mbhc-hphl-swh = <0>;
		qcom,msm-mbhc-gnd-swh = <0>;
		qcom,cdc-us-eu-gpios = <&cdc_us_euro_sw>;
		qcom,quin-mi2s-gpios = <&cdc_quin_mi2s_gpios>;

		asoc-platform = <&pcm0>, <&pcm1>, <&pcm2>, <&voip>, <&voice>,
				<&loopback>, <&compress>, <&hostless>,
				<&afe>, <&lsm>, <&routing>, <&cpe>, <&compr>,
				<&pcm_noirq>;
		asoc-platform-names = "msm-pcm-dsp.0", "msm-pcm-dsp.1",
				"msm-pcm-dsp.2", "msm-voip-dsp",
				"msm-pcm-voice", "msm-pcm-loopback",
				"msm-compress-dsp", "msm-pcm-hostless",
				"msm-pcm-afe", "msm-lsm-client",
				"msm-pcm-routing", "msm-cpe-lsm",
				"msm-compr-dsp", "msm-pcm-dsp-noirq";

		asoc-cpu = <&dai_pri_auxpcm>,
				<&dai_mi2s2>, <&dai_mi2s3>, <&dai_mi2s5>,
				<&sb_0_rx>, <&sb_0_tx>, <&sb_1_rx>, <&sb_1_tx>,
				<&sb_2_rx>, <&sb_2_tx>, <&sb_3_rx>, <&sb_3_tx>,
				<&sb_4_rx>, <&sb_4_tx>, <&sb_5_tx>,
				<&afe_pcm_rx>, <&afe_pcm_tx>,
				<&afe_proxy_rx>, <&afe_proxy_tx>,
				<&incall_record_rx>, <&incall_record_tx>,
				<&incall_music_rx>, <&incall_music_2_rx>,
				<&sb_5_rx>, <&bt_sco_rx>, <&bt_sco_tx>,
				<&int_fm_rx>, <&int_fm_tx>, <&sb_6_rx>;

		asoc-cpu-names = "msm-dai-q6-auxpcm.1",
				"msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3",
				"msm-dai-q6-mi2s.5", "msm-dai-q6-dev.16384",
				"msm-dai-q6-dev.16385", "msm-dai-q6-dev.16386",
				"msm-dai-q6-dev.16387", "msm-dai-q6-dev.16388",
				"msm-dai-q6-dev.16389", "msm-dai-q6-dev.16390",
				"msm-dai-q6-dev.16391", "msm-dai-q6-dev.16392",
				"msm-dai-q6-dev.16393", "msm-dai-q6-dev.16395",
				"msm-dai-q6-dev.224", "msm-dai-q6-dev.225",
				"msm-dai-q6-dev.241", "msm-dai-q6-dev.240",
				"msm-dai-q6-dev.32771", "msm-dai-q6-dev.32772",
				"msm-dai-q6-dev.32773", "msm-dai-q6-dev.32770",
				"msm-dai-q6-dev.16394", "msm-dai-q6-dev.12288",
				"msm-dai-q6-dev.12289", "msm-dai-q6-dev.12292",
				"msm-dai-q6-dev.12293", "msm-dai-q6-dev.16396";

		asoc-codec = <&stub_codec>, <&hdmi_dba>;
		asoc-codec-names = "msm-stub-codec.1", "msm-hdmi-dba-codec-rx";

		qcom,wsa-max-devs = <2>;
		qcom,wsa-devs = <&wsa881x_211>, <&wsa881x_212>,
				<&wsa881x_213>, <&wsa881x_214>;
		qcom,wsa-aux-dev-prefix = "SpkrLeft", "SpkrRight",
				"SpkrLeft", "SpkrRight";
	};

	cpe: qcom,msm-cpe-lsm {
		compatible = "qcom,msm-cpe-lsm";
	};

	wcd9xxx_intc: wcd9xxx-irq {
		status = "disabled";
		compatible = "qcom,wcd9xxx-irq";
		interrupt-controller;
		#interrupt-cells = <1>;
		interrupt-parent = <&tlmm>;
		qcom,gpio-connect = <&tlmm 73 0>;
		pinctrl-names = "default";
		pinctrl-0 = <&wcd_intr_default>;
	};

	clock_audio: audio_ext_clk {
		status = "disabled";
		compatible = "qcom,audio-ref-clk";
		clock-names = "osr_clk";
		qcom,node_has_rpm_clock;
		#clock-cells = <1>;
		pinctrl-names = "active", "sleep";
		pinctrl-0 = <&tasha_mclk_default>;
		pinctrl-1 = <&tasha_mclk_default>;
		qcom,audio-ref-clk-gpio = <&pm8953_gpios 1 0>;
		clocks = <&clock_gcc clk_div_clk2>;
	};

	wcd_rst_gpio: aaa@qq.com67 {
		status = "disabled";
		compatible = "qcom,msm-cdc-pinctrl";
		pinctrl-names = "aud_active", "aud_sleep";
		pinctrl-0 = <&cdc_reset_active>;
		pinctrl-1 = <&cdc_reset_sleep>;
	};
};

&slim_msm {
	status = "disabled";

	dai_slim: msm_dai_slim {
		status = "disabled";
		compatible = "qcom,msm-dai-slim";
		elemental-addr = [ff ff ff fe 17 02];
	};

	wcd9335: tasha_codec {
		status = "disabled";
		compatible = "qcom,tasha-slim-pgd";
		elemental-addr = [00 01 A0 01 17 02];

		qcom,cdc-slim-ifd = "tasha-slim-ifd";
		qcom,cdc-slim-ifd-elemental-addr = [00 00 A0 01 17 02];

		interrupt-parent = <&wcd9xxx_intc>;
		interrupts = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
				17 18 19 20 21 22 23 24 25 26 27 28 29 30>;

		qcom,wcd-rst-gpio-node = <&wcd_rst_gpio>;

		clock-names = "wcd_clk", "wcd_native_clk";
		clocks = <&clock_audio clk_audio_pmi_clk>,
			<&clock_audio clk_audio_ap_clk2>;

		qcom,cdc-static-supplies =
				"cdc-vdd-buck",
				"cdc-buck-sido",
				"cdc-vdd-tx-h",
				"cdc-vdd-rx-h",
				"cdc-vdd-px";

		qcom,cdc-on-demand-supplies = "cdc-vdd-mic-bias";
		qcom,cdc-micbias1-mv = <1800>;
		qcom,cdc-micbias2-mv = <1800>;
		qcom,cdc-micbias3-mv = <1800>;
		qcom,cdc-micbias4-mv = <1800>;

		qcom,cdc-dmic-sample-rate = <2400000>;
		qcom,cdc-mclk-clk-rate = <9600000>;

		cdc-vdd-buck-supply = <&eldo2_8953>;
		qcom,cdc-vdd-buck-voltage = <1800000 1800000>;
		qcom,cdc-vdd-buck-current = <650000>;

		cdc-buck-sido-supply = <&eldo2_8953>;
		qcom,cdc-buck-sido-voltage = <1800000 1800000>;
		qcom,cdc-buck-sido-current = <150000>;

		cdc-vdd-tx-h-supply = <&eldo2_8953>;
		qcom,cdc-vdd-tx-h-voltage = <1800000 1800000>;
		qcom,cdc-vdd-tx-h-current = <25000>;

		cdc-vdd-rx-h-supply = <&eldo2_8953>;
		qcom,cdc-vdd-rx-h-voltage = <1800000 1800000>;
		qcom,cdc-vdd-rx-h-current = <25000>;

		cdc-vdd-px-supply = <&eldo2_8953>;
		qcom,cdc-vdd-px-voltage = <1800000 1800000>;
		qcom,cdc-vdd-px-current = <10000>;

		cdc-vdd-mic-bias-supply = <&pm8953_l13>;
		qcom,cdc-vdd-mic-bias-voltage = <3125000 3125000>;
		qcom,cdc-vdd-mic-bias-current = <15000>;
	};
};
&pm8953_gpios {
	aaa@qq.com {
		status = "ok";
		qcom,mode = <1>;
		qcom,pull = <5>;
		qcom,vin-sel = <0>;
		qcom,src-sel = <2>;
		qcom,master-en = <1>;
		qcom,out-strength = <2>;
	};

	tasha_mclk {
		tasha_mclk_default: tasha_mclk_default{
			pins = "gpio1";
			function = "func1";
			qcom,drive-strength = <2>;
			power-source = <0>;
			bias-disable;
			output-low;
		};
	};
};

&pm8953_1 {
	pmic_analog_codec: analog-aaa@qq.com {
		status = "okay";
		compatible = "qcom,pmic-analog-codec";
		reg = <0xf000 0x200>;
		#address-cells = <2>;
		#size-cells = <0>;
		interrupt-parent = <&spmi_bus>;
		interrupts = <0x1 0xf0 0x0 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x1 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x2 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x3 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x4 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x5 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x6 IRQ_TYPE_NONE>,
			<0x1 0xf0 0x7 IRQ_TYPE_NONE>,
			<0x1 0xf1 0x0 IRQ_TYPE_NONE>,
			<0x1 0xf1 0x1 IRQ_TYPE_NONE>,
			<0x1 0xf1 0x2 IRQ_TYPE_NONE>,
			<0x1 0xf1 0x3 IRQ_TYPE_NONE>,
			<0x1 0xf1 0x4 IRQ_TYPE_NONE>,
			<0x1 0xf1 0x5 IRQ_TYPE_NONE>;
		interrupt-names = "spk_cnp_int",
				"spk_clip_int",
				"spk_ocp_int",
				"ins_rem_det1",
				"but_rel_det",
				"but_press_det",
				"ins_rem_det",
				"mbhc_int",
				"ear_ocp_int",
				"hphr_ocp_int",
				"hphl_ocp_det",
				"ear_cnp_int",
				"hphr_cnp_int",
				"hphl_cnp_int";
		qcom,speaker-pa = <&tlmm 63 0>;//kangting add speaker PA //add patch

		cdc-vdda-cp-supply = <&pm8953_s4>;
		qcom,cdc-vdda-cp-voltage = <1900000 2050000>;
		qcom,cdc-vdda-cp-current = <500000>;

		cdc-vdd-io-supply = <&pm8953_l5>;
		qcom,cdc-vdd-io-voltage = <1800000 1800000>;
		qcom,cdc-vdd-io-current = <5000>;

		cdc-vdd-pa-supply = <&pm8953_s4>;
		qcom,cdc-vdd-pa-voltage = <1900000 2050000>;
		qcom,cdc-vdd-pa-current = <260000>;

		cdc-vdd-mic-bias-supply = <&pm8953_l13>;
		qcom,cdc-vdd-mic-bias-voltage = <3125000 3125000>;
		qcom,cdc-vdd-mic-bias-current = <5000>;

		qcom,cdc-mclk-clk-rate = <9600000>;

		qcom,cdc-static-supplies = "cdc-vdd-io",
					"cdc-vdd-pa",
					"cdc-vdda-cp";

		qcom,cdc-on-demand-supplies = "cdc-vdd-mic-bias";

		msm_digital_codec: msm-dig-codec {
			compatible = "qcom,msm-digital-codec";
			reg = <0xc0f0000 0x0>;
		};
	};
};

vendor\qcom\opensource\audio-kernel\asoc\codecs\sdm660_cdc\msm-analog-cdc.h

struct sdm660_cdc_priv {
	struct device *dev;
	u32 num_of_supplies;
	struct regulator_bulk_data *supplies;
	...........................................
	/* compander used for each rx chain */
	bool spk_boost_set;
	bool ear_pa_boost_set;
	bool ext_spk_boost_set;
	bool ext_spk_pa_set;//kangting add 
	int spk_pa_gpio; //kangting add 
	..........................................

vendor/qcom/opensource/audio-kernel/asoc/codecs/sdm660_cdc/msm-analog-cdc.c

#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/printk.h>
#include <linux/debugfs.h>
#include <linux/of_gpio.h> //add by zhaojr
#include <linux/gpio.h>  //add by zhaojr
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
.................................................................................
//kangting add start
static int msm_anlg_cdc_ext_spk_pa_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct sdm660_cdc_priv *sdm660_cdc =
					snd_soc_codec_get_drvdata(codec);

	if (sdm660_cdc->ext_spk_pa_set == false)
		ucontrol->value.integer.value[0] = 0;
	else
		ucontrol->value.integer.value[0] = 1;

	dev_err(codec->dev, "%s: sdm660_cdc->ext_spk_pa_set = %d\n",
				__func__, sdm660_cdc->ext_spk_pa_set);
	return 0;
}

static int msm_anlg_cdc_ext_spk_pa_set(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct sdm660_cdc_priv *sdm660_cdc =
					snd_soc_codec_get_drvdata(codec);

	dev_err(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
		__func__, ucontrol->value.integer.value[0]);

	switch (ucontrol->value.integer.value[0]) {
	case 0:
		gpio_direction_output(sdm660_cdc->spk_pa_gpio,1);
		gpio_set_value(sdm660_cdc->spk_pa_gpio,0);
		udelay(600);
		sdm660_cdc->ext_spk_pa_set = false;
		break;
	case 1:
		gpio_direction_output(sdm660_cdc->spk_pa_gpio,1);
		gpio_set_value(sdm660_cdc->spk_pa_gpio,0);
		udelay(8);
		gpio_set_value(sdm660_cdc->spk_pa_gpio,1);
		udelay(8);
		gpio_set_value(sdm660_cdc->spk_pa_gpio,0);
		udelay(8);
		gpio_set_value(sdm660_cdc->spk_pa_gpio,1);
		sdm660_cdc->ext_spk_pa_set = true;
		break;
	default:
		return -EINVAL;
	}
	dev_err(codec->dev, "%s: sdm660_cdc->ext_spk_pa_set = %d\n",
		__func__, sdm660_cdc->ext_spk_pa_set);
	return 0;
}
//kangting end
...............................
//kangting start
static const char * const msm_anlg_cdc_ext_spk_pa_ctrl_text[] = {
		"DISABLE", "ENABLE"};
static const struct soc_enum msm_anlg_cdc_ext_spk_pa_ctl_enum[] = {
		SOC_ENUM_SINGLE_EXT(2, msm_anlg_cdc_ext_spk_pa_ctrl_text),
};
//kangting end
........................................................
static const struct snd_kcontrol_new msm_anlg_cdc_snd_controls[] = {
   .........................................................................
	SOC_ENUM_EXT("Ext Spk Boost", msm_anlg_cdc_ext_spk_boost_ctl_enum[0],
		msm_anlg_cdc_ext_spk_boost_get, msm_anlg_cdc_ext_spk_boost_set),
	//kangting start
	SOC_ENUM_EXT("SPK PA", msm_anlg_cdc_ext_spk_pa_ctl_enum[0],
		msm_anlg_cdc_ext_spk_pa_get, msm_anlg_cdc_ext_spk_pa_set),
	//kangting end 
	.....................................................................
};
static int msm_anlg_cdc_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct sdm660_cdc_priv *sdm660_cdc = NULL;
	struct sdm660_cdc_pdata *pdata;
	int adsp_state;
	..........................................................
	wcd9xxx_spmi_set_dev(pdev, 0);
	wcd9xxx_spmi_set_dev(pdev, 1);
	if (wcd9xxx_spmi_irq_init()) {
		dev_err(&pdev->dev,
			"%s: irq initialization failed\n", __func__);
	} else {
		dev_dbg(&pdev->dev,
			"%s: irq initialization passed\n", __func__);
	}
	dev_set_drvdata(&pdev->dev, sdm660_cdc);
	//kangting add
	sdm660_cdc->spk_pa_gpio = of_get_named_gpio(pdev->dev.of_node, "qcom,speaker-pa", 0);
	if (!gpio_is_valid(sdm660_cdc->spk_pa_gpio))
		pr_err("%s, sdm660_cdc->spk_pa_gpio not specified\n",__func__);
	else{
		pr_err("%s, sdm660_cdc->spk_pa_gpio is %d\n",__func__,sdm660_cdc->spk_pa_gpio);
		ret = gpio_request(sdm660_cdc->spk_pa_gpio, "spk_pa");
		if (ret) {
			pr_err("request spk_pa_gpio failed, ret=%d\n",ret);
			gpio_free(sdm660_cdc->spk_pa_gpio);
		}
	}
	//kangting end
	
	ret = snd_soc_register_codec(&pdev->dev,
				     &soc_codec_dev_sdm660_cdc,
				     msm_anlg_cdc_i2s_dai,
				     ARRAY_SIZE(msm_anlg_cdc_i2s_dai));
  ..............................................................				    
}

hardware\qcom\audio\configs\msm8953\mixer_paths_mtp.xml

//代码中add部分是添加的代码部分
<mixer>
   .................................................................................
	<path name="adc3">
        <ctl name="ADC3 Volume" value="6" />
        <ctl name="DEC1 MUX" value="ADC2" />
        <ctl name="ADC2 MUX" value="INP3" />
    </path>

    <path name="hdmi">
    </path>

    <path name="speaker">
         //电路原理图中声音从speaker出来时打开
        <ctl name="RX3 MIX1 INP1" value="RX1" />  //speaker start
        <ctl name="SPK" value="Switch" />    //speaker end
        //结束speaker输出配置
        //声音从EAR出来时打开以下代码
	    <ctl name="RX1 MIX1 INP1" value="RX1" />  // EAR add start
        <ctl name="RDAC2 MUX" value="RX1" />
        <ctl name="RX1 Digital Volume" value="84" />
        <ctl name="EAR PA Gain" value="POS_6_DB" />
        <ctl name="EAR_S" value="Switch" />
		<ctl name="SPK PA" value="ENABLE" />   //add end
		//结束EAR输出配置
    </path>
    <!--<path name="speaker">           
    	  <ctl name="RX3 MIX1 INP1" value="RX1" />
          <ctl name="SPK" value="Switch" />
    </path>-->

    <path name="speaker-and-hdmi">
        <path name="speaker" />
        <path name="hdmi" />
    </path>
    ...........................................
    <path name="speaker-mic">
        <path name="adc1" />  //录音使用adc1,不使用adc3
        <ctl name="IIR1 INP1 MUX" value="DEC1" />
   </path>

    <path name="handset">
        <ctl name="RX1 MIX1 INP1" value="RX1" />
        <ctl name="RDAC2 MUX" value="RX1" />
        <ctl name="RX1 Digital Volume" value="84" />
        <ctl name="EAR PA Gain" value="POS_6_DB" />
        <ctl name="EAR_S" value="Switch" />
	   <ctl name="SPK PA" value="ENABLE" />  //add SPK PA enable
    </path>
    <path name="handset-mic">
        <path name="adc1" />   //录音使用adc1,不使用adc3
        <ctl name="IIR1 INP1 MUX" value="DEC1" />
    </path>
相关标签: 高通平台 Audio