Zram内存压缩-开机自启动配置

路由没有完全通。但是其它部分已经完全正常工作了,你在alsamixer肯定能看到注册的声卡。你是不是用的原版内核里的rt5659.c,我传的那份ucm conf是根据我从小米官方源码改来的rt5659.c来配置通路由的,所以直接用那份无法完全连通音频路由。

完全连通的话,tfa989x里面的这些widget全部都会在路由path里的,连通至OUT这个widget即最终喇叭输出。

static const struct snd_soc_dapm_route tfa989x_dapm_routes[] = {
	{"OUT", NULL, "AMPE"},
	{"AMPE", NULL, "POWER"},
	{"AMPE", NULL, "Amp Input"},
	{"Amp Input", "Left", "AIFINL"},
	{"Amp Input", "Right", "AIFINR"},
};

好家伙你这是替官方做了一版for you

对比小米官方rt5659.c默认连通的路由,发现原版内核默认连通的音频widget路由里IF3 ADC Mux是连通的,但IF2 ADC Mux却没有连通。


所以可以尝试手动在conf文件里设置两个mux的值,

	{ "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" },
	{ "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" },
	{ "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" },
	{ "IF2 ADC Mux", "DAC_REF", "DAC_REF" },
	{ "IF2 ADC", NULL, "IF2 ADC Mux"},
	{ "IF2 ADC", NULL, "I2S2" },

	{ "IF3 ADC Mux", "IF_ADC1", "IF_ADC1" },
	{ "IF3 ADC Mux", "IF_ADC2", "IF_ADC2" },
	{ "IF3 ADC Mux", "Stereo2_ADC_L/R", "Stereo2 ADC LR" },
	{ "IF3 ADC Mux", "DAC_REF", "DAC_REF" },
	{ "IF3 ADC", NULL, "IF3 ADC Mux"},
	{ "IF3 ADC", NULL, "I2S3" },

cset "name='IF2 ADC Mux' DAC_REF"
cset "name='IF3 ADC Mux' IF_ADC1"

完整的HiFi.conf

SectionVerb {

    EnableSequence [

	    # media mixer settings
	    #   compress
	    cset "name='media0_in Gain 0 Switch' on"
	    cset "name='media0_in Gain 0 Volume' 0"

	    #   normal
	    cset "name='media1_in Gain 0 Switch' on"
	    cset "name='media1_in Gain 0 Volume' 0"
	    #   swm loopback
	    cset "name='media2_in Gain 0 Switch' off"
	    cset "name='media2_in Gain 0 Volume' 0%"
	    #   deep buffer
	    cset "name='media3_in Gain 0 Switch' on"
	    cset "name='media3_in Gain 0 Volume' 0"

	    cset "name='media0_out mix 0 media0_in Switch' on"
	    cset "name='media0_out mix 0 media1_in Switch' on"
	    cset "name='media0_out mix 0 media2_in Switch' off"
	    cset "name='media0_out mix 0 media3_in Switch' on"

	    cset "name='media1_out mix 0 media0_in Switch' off"
	    cset "name='media1_out mix 0 media1_in Switch' off"
	    cset "name='media1_out mix 0 media2_in Switch' off"
	    cset "name='media1_out mix 0 media3_in Switch' off"

	    cset "name='pcm0_in Gain 0 Switch' on"
	    cset "name='pcm0_in Gain 0 Volume' 0"

	    cset "name='pcm1_in Gain 0 Switch' off"
	    cset "name='pcm1_in Gain 0 Volume' 0%"

	    # codec0_out settings (used if SSP2 is connected)
	    cset "name='codec_out0 mix 0 codec_in0 Switch' off"
	    cset "name='codec_out0 mix 0 codec_in1 Switch' off"
	    cset "name='codec_out0 mix 0 media_loop1_in Switch' off"
	    cset "name='codec_out0 mix 0 media_loop2_in Switch' off"
	    cset "name='codec_out0 mix 0 pcm0_in Switch' on"
	    cset "name='codec_out0 mix 0 pcm1_in Switch' off"
	    cset "name='codec_out0 mix 0 sprot_loop_in Switch' off"
	    cset "name='codec_out0 Gain 0 Switch' on"
	    cset "name='codec_out0 Gain 0 Volume' 6"

	    # modem_out settings (used if SSP0 is connected)
	    cset "name='modem_out mix 0 codec_in0 Switch' off"
	    cset "name='modem_out mix 0 codec_in1 Switch' off"
	    cset "name='modem_out mix 0 media_loop1_in Switch' off"
	    cset "name='modem_out mix 0 media_loop2_in Switch' off"
	    cset "name='modem_out mix 0 pcm0_in Switch' on"
	    cset "name='modem_out mix 0 pcm1_in Switch' off"
	    cset "name='modem_out mix 0 sprot_loop_in Switch' off"
	    cset "name='modem_out Gain 0 Switch' on"
	    cset "name='modem_out Gain 0 Volume' 0"

	    # input settings

	    # input used when SSP2 is connected
	    cset "name='codec_in0 Gain 0 Switch' on"
	    cset "name='codec_in0 Gain 0 Volume' 0"

	    # input used when SSP0 is connected
	    cset "name='modem_in Gain 0 Switch' on"
	    cset "name='modem_in Gain 0 Volume' 0"

	    # pcm1_out settings
	    cset "name='pcm1_out mix 0 codec_in0 Switch' on"
	    cset "name='pcm1_out mix 0 modem_in Switch' on"
	    cset "name='pcm1_out mix 0 codec_in1 Switch' off"
	    cset "name='pcm1_out mix 0 media_loop1_in Switch' off"
	    cset "name='pcm1_out mix 0 media_loop2_in Switch' off"
	    cset "name='pcm1_out mix 0 pcm0_in Switch' off"
	    cset "name='pcm1_out mix 0 pcm1_in Switch' off"
	    cset "name='pcm1_out mix 0 sprot_loop_in Switch' off"

	    cset "name='pcm1_out Gain 0 Switch' on"
	    cset "name='pcm1_out Gain 0 Volume' 0"

	    # disable codec_out1
	    cset "name='codec_out1 mix 0 codec_in0 Switch' off"
	    cset "name='codec_out1 mix 0 codec_in1 Switch' off"
	    cset "name='codec_out1 mix 0 media_loop1_in Switch' off"
	    cset "name='codec_out1 mix 0 media_loop2_in Switch' off"
	    cset "name='codec_out1 mix 0 pcm0_in Switch' off"
	    cset "name='codec_out1 mix 0 pcm1_in Switch' off"
	    cset "name='codec_out1 mix 0 sprot_loop_in Switch' off"
	    cset "name='codec_out1 Gain 0 Switch' off"
	    cset "name='codec_out1 Gain 0 Volume' 0%"

	    # disable codec_in1
	    cset "name='codec_in1 Gain 0 Switch' off"
	    cset "name='codec_in1 Gain 0 Volume' 0%"

	    # disable all loops
	    cset "name='media_loop1_out mix 0 codec_in0 Switch' off"
	    cset "name='media_loop1_out mix 0 codec_in1 Switch' off"
	    cset "name='media_loop1_out mix 0 media_loop1_in Switch' off"
	    cset "name='media_loop1_out mix 0 media_loop2_in Switch' off"
	    cset "name='media_loop1_out mix 0 pcm0_in Switch' off"
	    cset "name='media_loop1_out mix 0 pcm1_in Switch' off"
	    cset "name='media_loop1_out mix 0 sprot_loop_in Switch' off"

	    cset "name='media_loop2_out mix 0 codec_in0 Switch' off"
	    cset "name='media_loop2_out mix 0 codec_in1 Switch' off"
	    cset "name='media_loop2_out mix 0 media_loop1_in Switch' off"
	    cset "name='media_loop2_out mix 0 media_loop2_in Switch' off"
	    cset "name='media_loop2_out mix 0 pcm0_in Switch' off"
	    cset "name='media_loop2_out mix 0 pcm1_in Switch' off"
	    cset "name='media_loop2_out mix 0 sprot_loop_in Switch' off"

	    cset "name='sprot_loop_out mix 0 codec_in0 Switch' off"
	    cset "name='sprot_loop_out mix 0 codec_in1 Switch' off"
	    cset "name='sprot_loop_out mix 0 media_loop1_in Switch' off"
	    cset "name='sprot_loop_out mix 0 media_loop2_in Switch' off"
	    cset "name='sprot_loop_out mix 0 pcm0_in Switch' off"
	    cset "name='sprot_loop_out mix 0 pcm1_in Switch' off"
	    cset "name='sprot_loop_out mix 0 sprot_loop_in Switch' off"
	    
	    cset "name='IF2 ADC Mux' DAC_REF"
	    cset "name='IF3 ADC Mux' IF_ADC1"
	    
	    cset "name='DAC1 Playback Volume' 6"
    ]

	DisableSequence [

	]
}

SectionDevice."Speaker".0 {
	Value {

	}

	EnableSequence [

	]
	DisableSequence [

	]
}
1 个赞

感谢指点,现在是系统设置里能看到设备。但是扬声器声音很小, alsamixer调adc1为1%就好了,现在是1%声音还是很大

1 个赞

codec_out0 Gain 0 和 DAC1 Playback共同决定音量,可以组合式调一下。

这里初始值我设置为6是比较小音量的。

cset "name='codec_out0 Gain 0 Volume' 6"

cset "name='DAC1 Playback Volume' 6"

百分比设置可能没法太精准控制,建议使用数量设置。命令行可以直接用 amixer cset xxxxxxxx

1 个赞

奇怪,重启之后设置里就看不见设备了。cat /proc/asound/cards还能看见。我这有点玄学

1 个赞

也有可能是一些默认连通的路由干扰的问题,比较大可能是TDM Data Mux这个widget的值影响。

	{ "TDM Data Mux", "AD1:AD2:DAC:NUL", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD1:AD2:NUL:DAC", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD1:DAC:AD2:NUL", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD1:DAC:NUL:AD2", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD1:NUL:DAC:AD2", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD1:NUL:AD2:DAC", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD2:AD1:DAC:NUL", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD2:AD1:NUL:DAC", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD2:DAC:AD1:NUL", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD2:DAC:NUL:AD1", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD2:NUL:DAC:AD1", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "AD1:NUL:AD1:DAC", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "DAC:AD1:AD2:NUL", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "DAC:AD1:NUL:AD2", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "DAC:AD2:AD1:NUL", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "DAC:AD2:NUL:AD1", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "DAC:NUL:DAC:AD2", "TDM AD2:DAC" },
	{ "TDM Data Mux", "DAC:NUL:AD2:DAC", "TDM AD2:DAC" },
	{ "TDM Data Mux", "NUL:AD1:AD2:DAC", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "NUL:AD1:DAC:AD2", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "NUL:AD2:AD1:DAC", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "NUL:AD2:DAC:AD1", "TDM AD1:AD2:DAC" },
	{ "TDM Data Mux", "NUL:DAC:DAC:AD2", "TDM AD2:DAC" },
	{ "TDM Data Mux", "NUL:DAC:AD2:DAC", "TDM AD2:DAC" },

你可以把所有的值尝试一遍看是否影响。

cset "name='TDM Data Mux' AD1:AD2:DAC:NUL"
...
1 个赞

看了一下,不用全部试,用下面四个其中之一的值试一下就可以确认是不是这个值的问题。

	{ "TDM Data Mux", "DAC:NUL:DAC:AD2", "TDM AD2:DAC" },
	{ "TDM Data Mux", "DAC:NUL:AD2:DAC", "TDM AD2:DAC" },
	{ "TDM Data Mux", "NUL:DAC:DAC:AD2", "TDM AD2:DAC" },
	{ "TDM Data Mux", "NUL:DAC:AD2:DAC", "TDM AD2:DAC" },

如果没有用的话,试试把conf里原本开启的pcm1_out mix 0 codec_in0关掉,这个是控制录音进入路由的开关,但录音部分现在完全还没处理,有可能是它造成的问题。

//cset "name='pcm1_out mix 0 codec_in0 Switch' on"
cset "name='pcm1_out mix 0 codec_in0 Switch' off"
1 个赞

试了这4+1没用

1 个赞

重启后的日志输出看一下,看看音频widget的路由

1 个赞
[   13.243277] tfa989x test 0 
[   13.243292] tfa989x check_functionality OK 
[   13.243776] tfa989x dev name: i2c-tfa9890:00
[   13.243785] tfa989x test 1 
[   13.243798] tfa989x i2c-tfa9890:00: supply vddd not found, using dummy regulator
[   13.244064] tfa989x test 2 
[   13.252368] tfa989x test 3 
[   13.252381] tfa989x revision number, expected 0x80, got 0x80
[   13.272427] cfg80211: loaded regulatory.db is malformed or signature is missing/invalid
[   13.276785] tfa989x test 4 
[   13.308433] tfa989x test 0 
[   13.308449] tfa989x check_functionality OK 
[   13.308654] tfa989x dev name: i2c-tfa9890:01
[   13.308663] tfa989x test 1 
[   13.308677] tfa989x i2c-tfa9890:01: supply vddd not found, using dummy regulator
[   13.333416] tfa989x test 2 
[   13.339133] tfa989x test 3 
[   13.339148] tfa989x revision number, expected 0x80, got 0x80
[   13.344274] tfa989x test 4 
[   13.352192] Bluetooth: hci0: BCM: chip id 101
[   13.352576] Bluetooth: hci0: BCM: features 0x2f
[   13.353590] Bluetooth: hci0: BCM4354A2
[   13.353608] Bluetooth: hci0: BCM4356A2 (001.003.015) build 0000
[   13.369225] usbcore: registered new interface driver brcmfmac
[   13.369620] brcmfmac 0000:01:00.0: enabling device (0000 -> 0002)
[   13.370230] Bluetooth: hci0: BCM4356A2 'brcm/BCM4356A2.hcd' Patch
[   13.457148] input: PC Speaker as /devices/platform/pcspkr/input/input13
[   13.490352] Error: Driver 'pcspkr' is already registered, aborting...
[   13.567603] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4356-pcie for chip BCM4356/2
[   13.567951] brcmfmac 0000:01:00.0: Direct firmware load for brcm/brcmfmac4356-pcie.Xiaomi Inc-Mipad2.bin failed with error -2
[   13.608904] brcmfmac 0000:01:00.0: Direct firmware load for brcm/brcmfmac4356-pcie.txcap_blob failed with error -2
[   13.715949] ACPI: \_SB_.PCI0.I2C4.CAM3: INT33BE:00: Using DSM entry CsiPort=1
[   13.716067] ACPI: \_SB_.PCI0.I2C4.CAM3: INT33BE:00: Using DSM entry CsiLanes=2
[   13.716160] ACPI: \_SB_.PCI0.I2C4.CAM3: INT33BE:00: Sensor module id: '12P2BA535'
[   13.716916] ACPI: \_SB_.PCI0.I2C4.CAM3: INT33BE:00: reset-gpios crs 0 \_SB.GPO1 pin 50 active-low
[   13.716932] ACPI: \_SB_.PCI0.I2C4.CAM3: INT33BE:00: powerdown-gpios crs 1 \_SB.GPO1 pin 54 active-low
[   13.717281] atomisp-isp2 0000:00:03.0: Found supported sensor INT33BE:00
[   13.717634] atomisp-isp2 0000:00:03.0: Connected 1 cameras
[   13.772146] cryptd: max_cpu_qlen set to 1000
[   13.822970] SSE version of gcm_enc/dec engaged.
[   13.841623] input: gpio-keys as /devices/platform/ACPI0011:00/gpio-keys.35.auto/input/input14
[   13.846781] input: gpio-keys as /devices/platform/ACPI0011:00/gpio-keys.36.auto/input/input15
[   13.927721] brcmfmac: brcmf_c_process_txcap_blob: no txcap_blob available (err=-2)
[   13.929792] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4356/2 wl0: Aug 29 2019 02:05:27 version 7.35.180.197 (r722171 CY) FWID 01-4c8512f9
[   14.047517] ov5693 i2c-INT33BE:00: supply avdd not found, using dummy regulator
[   14.047661] ov5693 i2c-INT33BE:00: supply dovdd not found, using dummy regulator
[   14.047686] ov5693 i2c-INT33BE:00: supply dvdd not found, using dummy regulator
[   14.054234] rt5659 mach pdev name cht-bsw-rt5659
[   14.054244] rt5659 mach id 10EC5659
[   14.054246] rt5659 mach drv_name cht-bsw-rt5659
[   14.054248] rt5659 mach fw_filename intel/fw_sst_22a8.bin
[   14.054251] rt5659 index 2 dai codec name i2c-10EC5659:00
[   14.054306] rt5659 acpi_device name 10EC5659:01
[   14.054308] rt5659 fixuped index 2 dai codec name i2c-10EC5659:01
[   14.054310] rt5659 mach platform_name sst-mfld-platform
[   14.054312] rt5659 mach test 1
[   14.054320] rt5659 mach test 2
[   14.056515] ov5693 i2c-INT33BE:00: Supports crop native 2624x1956 active 2592x1944 binning 1
[   14.056532] atomisp-isp2 0000:00:03.0: detected 1 camera sensors
[   14.064531] tfa989x received fmt: 16385
[   14.151303] rt5659 mach test 3
[   14.295740] intel_rapl_common: Found RAPL domain package
[   14.295756] intel_rapl_common: Found RAPL domain core
[   14.439946] Bluetooth: hci0: BCM: features 0x2f
[   14.441175] Bluetooth: hci0: BCM4356 37.4MHz Xiaomi A3-0084
[   14.441191] Bluetooth: hci0: BCM4356A2 (001.003.015) build 0268
[   14.471398] NET: Registered PF_QIPCRTR protocol family
[   14.746882] brcmfmac 0000:01:00.0 wlp1s0: renamed from wlan0
[   14.891092] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   14.891112] Bluetooth: BNEP filters: protocol multicast
[   14.891126] Bluetooth: BNEP socket layer initialized
[   14.919292] Bluetooth: MGMT ver 1.22
[   14.950616] NET: Registered PF_ALG protocol family
[   16.862747] intel_sst_acpi 808622A8:00: FW Version 01.0b.02.02
[   16.864301] cht_aif1_startup runtime=00000000b784a506
[   16.864383] 6 paths got
[   16.864386] rt5659 path widget: name=media1_in, sname=(null)
[   16.864390] rt5659 path widget: name=media0_out mix 0, sname=(null)
[   16.864393] rt5659 path widget: name=media0_out, sname=(null)
[   16.864395] rt5659 path widget: name=pcm0_in, sname=(null)
[   16.864398] rt5659 path widget: name=modem_out mix 0, sname=(null)
[   16.864400] rt5659 path widget: name=modem_out, sname=(null)
[   16.864402] rt5659 path widget: name=codec_out0 mix 0, sname=(null)
[   16.864405] rt5659 path widget: name=codec_out0, sname=(null)
[   16.864407] rt5659 path widget: name=ssp2 Tx, sname=ssp2 Tx
[   16.864410] rt5659 path widget: name=AIF1 Playback, sname=AIF1 Playback
[   16.864412] rt5659 path widget: name=AIF1RX, sname=AIF1 Playback
[   16.864415] rt5659 path widget: name=IF1 DAC2, sname=(null)
[   16.864417] rt5659 path widget: name=IF1 DAC2 R, sname=(null)
[   16.864419] rt5659 path widget: name=IF1 DAC2 L, sname=(null)
[   16.864421] rt5659 path widget: name=IF1 DAC1, sname=(null)
[   16.864424] rt5659 path widget: name=SPDIF Mux, sname=(null)
[   16.864426] rt5659 path widget: name=SPDIF, sname=(null)
[   16.864428] rt5659 path widget: name=IF1 DAC1 R, sname=(null)
[   16.864431] rt5659 path widget: name=DAC R1 Mux, sname=(null)
[   16.864433] rt5659 path widget: name=DAC1 MIXR, sname=(null)
[   16.864435] rt5659 path widget: name=DAC_REF, sname=(null)
[   16.864437] rt5659 path widget: name=IF2 ADC Mux, sname=(null)
[   16.864439] rt5659 path widget: name=IF2 ADC, sname=(null)
[   16.864442] rt5659 path widget: name=IF2 ADC Swap Mux, sname=(null)
[   16.864444] rt5659 path widget: name=AIF2TX, sname=AIF2 Capture
[   16.864446] rt5659 path widget: name=AIF2 Capture, sname=AIF2 Capture
[   16.864449] rt5659 path widget: name=rt5659_AIF2-TFA989x_Speaker_L-playback, sname=(null)
[   16.864451] rt5659 path widget: name=HiFi Playback, sname=HiFi Playback
[   16.864454] rt5659 path widget: name=AIFINR, sname=HiFi Playback
[   16.864456] rt5659 path widget: name=AIFINL, sname=HiFi Playback
[   16.864459] rt5659 path widget: name=Amp Input, sname=(null)
[   16.864461] rt5659 path widget: name=AMPE, sname=(null)
[   16.864463] rt5659 path widget: name=OUT, sname=(null)
[   16.864466] rt5659 path widget: name=TDM AD2:DAC, sname=(null)
[   16.864468] rt5659 path widget: name=TDM Data Mux, sname=(null)
[   16.864470] rt5659 path widget: name=IF1 67 ADC Swap Mux, sname=(null)
[   16.864472] rt5659 path widget: name=IF1 ADC, sname=(null)
[   16.864474] rt5659 path widget: name=AIF1TX, sname=AIF1 Capture
[   16.864477] rt5659 path widget: name=AIF1 Capture, sname=AIF1 Capture
[   16.864479] rt5659 path widget: name=ssp2 Rx, sname=ssp2 Rx
[   16.864481] rt5659 path widget: name=codec_in1, sname=(null)
[   16.864484] rt5659 path widget: name=codec_in0, sname=(null)
[   16.864486] rt5659 path widget: name=pcm1_out mix 0, sname=(null)
[   16.864488] rt5659 path widget: name=pcm1_out, sname=(null)
[   16.864490] rt5659 path widget: name=Headset Capture, sname=Headset Capture
[   16.864493] rt5659 path widget: name=IF1 45 ADC Swap Mux, sname=(null)
[   16.864495] rt5659 path widget: name=IF1 23 ADC Swap Mux, sname=(null)
[   16.864497] rt5659 path widget: name=IF1 01 ADC Swap Mux, sname=(null)
[   16.864500] rt5659 path widget: name=TDM AD1:AD2:DAC, sname=(null)
[   16.864502] rt5659 path widget: name=IF1 DAC1 L, sname=(null)
[   16.864504] rt5659 path widget: name=DAC L1 Mux, sname=(null)
[   16.864506] rt5659 path widget: name=DAC1 MIXL, sname=(null)
[   16.907454] tfa989x received sample_rate: 48000
[   16.948387] cht_aif1_startup runtime=00000000e3f354d9
[   16.948446] 6 paths got
[   16.948450] rt5659 path widget: name=media1_in, sname=(null)
[   16.948453] rt5659 path widget: name=media0_out mix 0, sname=(null)
[   16.948456] rt5659 path widget: name=media0_out, sname=(null)
[   16.948458] rt5659 path widget: name=pcm0_in, sname=(null)
[   16.948461] rt5659 path widget: name=modem_out mix 0, sname=(null)
[   16.948463] rt5659 path widget: name=modem_out, sname=(null)
[   16.948465] rt5659 path widget: name=codec_out0 mix 0, sname=(null)
[   16.948468] rt5659 path widget: name=codec_out0, sname=(null)
[   16.948470] rt5659 path widget: name=ssp2 Tx, sname=ssp2 Tx
[   16.948473] rt5659 path widget: name=AIF1 Playback, sname=AIF1 Playback
[   16.948475] rt5659 path widget: name=AIF1RX, sname=AIF1 Playback
[   16.948478] rt5659 path widget: name=IF1 DAC2, sname=(null)
[   16.948480] rt5659 path widget: name=IF1 DAC2 R, sname=(null)
[   16.948482] rt5659 path widget: name=IF1 DAC2 L, sname=(null)
[   16.948485] rt5659 path widget: name=IF1 DAC1, sname=(null)
[   16.948487] rt5659 path widget: name=SPDIF Mux, sname=(null)
[   16.948489] rt5659 path widget: name=SPDIF, sname=(null)
[   16.948492] rt5659 path widget: name=IF1 DAC1 R, sname=(null)
[   16.948494] rt5659 path widget: name=DAC R1 Mux, sname=(null)
[   16.948497] rt5659 path widget: name=DAC1 MIXR, sname=(null)
[   16.948499] rt5659 path widget: name=DAC_REF, sname=(null)
[   16.948501] rt5659 path widget: name=IF2 ADC Mux, sname=(null)
[   16.948503] rt5659 path widget: name=IF2 ADC, sname=(null)
[   16.948506] rt5659 path widget: name=IF2 ADC Swap Mux, sname=(null)
[   16.948508] rt5659 path widget: name=AIF2TX, sname=AIF2 Capture
[   16.948510] rt5659 path widget: name=AIF2 Capture, sname=AIF2 Capture
[   16.948513] rt5659 path widget: name=rt5659_AIF2-TFA989x_Speaker_L-playback, sname=(null)
[   16.948516] rt5659 path widget: name=HiFi Playback, sname=HiFi Playback
[   16.948518] rt5659 path widget: name=AIFINR, sname=HiFi Playback
[   16.948521] rt5659 path widget: name=AIFINL, sname=HiFi Playback
[   16.948523] rt5659 path widget: name=Amp Input, sname=(null)
[   16.948526] rt5659 path widget: name=AMPE, sname=(null)
[   16.948528] rt5659 path widget: name=OUT, sname=(null)
[   16.948530] rt5659 path widget: name=TDM AD2:DAC, sname=(null)
[   16.948533] rt5659 path widget: name=TDM Data Mux, sname=(null)
[   16.948535] rt5659 path widget: name=IF1 67 ADC Swap Mux, sname=(null)
[   16.948537] rt5659 path widget: name=IF1 ADC, sname=(null)
[   16.948539] rt5659 path widget: name=AIF1TX, sname=AIF1 Capture
[   16.948542] rt5659 path widget: name=AIF1 Capture, sname=AIF1 Capture
[   16.948544] rt5659 path widget: name=ssp2 Rx, sname=ssp2 Rx
[   16.948546] rt5659 path widget: name=codec_in1, sname=(null)
[   16.948549] rt5659 path widget: name=codec_in0, sname=(null)
[   16.948551] rt5659 path widget: name=pcm1_out mix 0, sname=(null)
[   16.948553] rt5659 path widget: name=pcm1_out, sname=(null)
[   16.948556] rt5659 path widget: name=Headset Capture, sname=Headset Capture
[   16.948558] rt5659 path widget: name=IF1 45 ADC Swap Mux, sname=(null)
[   16.948560] rt5659 path widget: name=IF1 23 ADC Swap Mux, sname=(null)
[   16.948563] rt5659 path widget: name=IF1 01 ADC Swap Mux, sname=(null)
[   16.948565] rt5659 path widget: name=TDM AD1:AD2:DAC, sname=(null)
[   16.948567] rt5659 path widget: name=IF1 DAC1 L, sname=(null)
[   16.948569] rt5659 path widget: name=DAC L1 Mux, sname=(null)
[   16.948572] rt5659 path widget: name=DAC1 MIXL, sname=(null)
[   16.954500] cht_aif1_startup runtime=00000000e3f354d9
[   16.954585] 6 paths got
[   16.954590] rt5659 path widget: name=media3_in, sname=(null)
[   16.954594] rt5659 path widget: name=media0_out mix 0, sname=(null)
[   16.954597] rt5659 path widget: name=media0_out, sname=(null)
[   16.954600] rt5659 path widget: name=pcm0_in, sname=(null)
[   16.954602] rt5659 path widget: name=modem_out mix 0, sname=(null)
[   16.954605] rt5659 path widget: name=modem_out, sname=(null)
[   16.954607] rt5659 path widget: name=codec_out0 mix 0, sname=(null)
[   16.954609] rt5659 path widget: name=codec_out0, sname=(null)
[   16.954612] rt5659 path widget: name=ssp2 Tx, sname=ssp2 Tx
[   16.954614] rt5659 path widget: name=AIF1 Playback, sname=AIF1 Playback
[   16.954617] rt5659 path widget: name=AIF1RX, sname=AIF1 Playback
[   16.954619] rt5659 path widget: name=IF1 DAC2, sname=(null)
[   16.954622] rt5659 path widget: name=IF1 DAC2 R, sname=(null)
[   16.954624] rt5659 path widget: name=IF1 DAC2 L, sname=(null)
[   16.954627] rt5659 path widget: name=IF1 DAC1, sname=(null)
[   16.954629] rt5659 path widget: name=SPDIF Mux, sname=(null)
[   16.954631] rt5659 path widget: name=SPDIF, sname=(null)
[   16.954634] rt5659 path widget: name=IF1 DAC1 R, sname=(null)
[   16.954636] rt5659 path widget: name=DAC R1 Mux, sname=(null)
[   16.954638] rt5659 path widget: name=DAC1 MIXR, sname=(null)
[   16.954641] rt5659 path widget: name=DAC_REF, sname=(null)
[   16.954643] rt5659 path widget: name=IF2 ADC Mux, sname=(null)
[   16.954645] rt5659 path widget: name=IF2 ADC, sname=(null)
[   16.954647] rt5659 path widget: name=IF2 ADC Swap Mux, sname=(null)
[   16.954650] rt5659 path widget: name=AIF2TX, sname=AIF2 Capture
[   16.954652] rt5659 path widget: name=AIF2 Capture, sname=AIF2 Capture
[   16.954654] rt5659 path widget: name=rt5659_AIF2-TFA989x_Speaker_L-playback, sname=(null)
[   16.954657] rt5659 path widget: name=HiFi Playback, sname=HiFi Playback
[   16.954660] rt5659 path widget: name=AIFINR, sname=HiFi Playback
[   16.954662] rt5659 path widget: name=AIFINL, sname=HiFi Playback
[   16.954665] rt5659 path widget: name=Amp Input, sname=(null)
[   16.954668] rt5659 path widget: name=AMPE, sname=(null)
[   16.954670] rt5659 path widget: name=OUT, sname=(null)
[   16.954672] rt5659 path widget: name=TDM AD2:DAC, sname=(null)
[   16.954675] rt5659 path widget: name=TDM Data Mux, sname=(null)
[   16.954677] rt5659 path widget: name=IF1 67 ADC Swap Mux, sname=(null)
[   16.954679] rt5659 path widget: name=IF1 ADC, sname=(null)
[   16.954681] rt5659 path widget: name=AIF1TX, sname=AIF1 Capture
[   16.954684] rt5659 path widget: name=AIF1 Capture, sname=AIF1 Capture
[   16.954686] rt5659 path widget: name=ssp2 Rx, sname=ssp2 Rx
[   16.954688] rt5659 path widget: name=codec_in1, sname=(null)
[   16.954691] rt5659 path widget: name=codec_in0, sname=(null)
[   16.954693] rt5659 path widget: name=pcm1_out mix 0, sname=(null)
[   16.954695] rt5659 path widget: name=pcm1_out, sname=(null)
[   16.954698] rt5659 path widget: name=Headset Capture, sname=Headset Capture
[   16.954700] rt5659 path widget: name=IF1 45 ADC Swap Mux, sname=(null)
[   16.954702] rt5659 path widget: name=IF1 23 ADC Swap Mux, sname=(null)
[   16.954705] rt5659 path widget: name=IF1 01 ADC Swap Mux, sname=(null)
[   16.954707] rt5659 path widget: name=TDM AD1:AD2:DAC, sname=(null)
[   16.954709] rt5659 path widget: name=IF1 DAC1 L, sname=(null)
[   16.954712] rt5659 path widget: name=DAC L1 Mux, sname=(null)
[   16.954714] rt5659 path widget: name=DAC1 MIXL, sname=(null)
[   16.987427] tfa989x received sample_rate: 48000
1 个赞

使用aplay指定设备是能播放的,也许是我这软件配置问题

1 个赞

那可能是ALSA的问题了,widget route是完全通的,应该没有问题,ALSA我也没有弄得很懂,太多琐碎的东西了。又或者是玄学问题,哈哈。
据我所知ALSA会去找Master Playback Volume这个widget名,有空也可以试试我之前那样在源码手动改一个音量widget名(conf里也要对应改),不知道会不会起作用。

1 个赞

是软件问题,又莫名其妙好了。
以下是修改方案。这么做会导致设置无法测试左右声道,不过这功能应该没多少人用
/usr/share/pipewire/pipewire.conf
249行 Dummy-Driver 设备后面定义。并设置 cset "name='DAC1 Playback Volume' 175"

    { factory = spa-node-factory
        args = {
            factory.name           = api.alsa.pcm.sink
            node.name              = "alsa_card.platfrom-cht-bsw-rt5659"
            node.description       = "PCM Device"
            media.class            = "Audio/Device"
            api.alsa.path          = "hw:0"
            api.alsa.period-size   = 1024
            api.alsa.headroom      = 0
            api.alsa.disable-mmap  = false
            api.alsa.disable-batch = false
            audio.format           = "S16LE"
            audio.rate             = 48000
            audio.channels         = 2
            audio.position         = "FL,FR"
        }
    }
2 个赞

取消右扬声器注释之后,进系统选左还是右声道,两个扬声器都响。

static const struct snd_soc_dapm_widget tfa989x_dapm_widgets[] = {
	SND_SOC_DAPM_OUTPUT("OUT"),
	SND_SOC_DAPM_SUPPLY("POWER", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_PWDN, 1, NULL, 0),
	SND_SOC_DAPM_OUT_DRV("AMPE", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_AMPE, 0, NULL, 0),

	SND_SOC_DAPM_MUX("Amp Input", SND_SOC_NOPM, 0, 0, &chsa_mux),
	SND_SOC_DAPM_AIF_IN("AIFINL", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_AIF_IN("AIFINR", "HiFi Playback", 1, SND_SOC_NOPM, 0, 0),
};

static const struct snd_soc_dapm_route tfa989x_dapm_routes[] = {
	{"OUT", NULL, "AMPE"},
	{"AMPE", NULL, "POWER"},
	{"AMPE", NULL, "Amp Input"},
	{"Amp Input", "Left", "AIFINL"},
	{"Amp Input", "Right", "AIFINR"},
};
// 第二芯片
static const struct snd_soc_dapm_widget tfa9890_dapm_widgets[] = {
	SND_SOC_DAPM_OUTPUT("OUT1"),
	SND_SOC_DAPM_SUPPLY("POWER1", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_PWDN, 1, NULL, 0),
	SND_SOC_DAPM_OUT_DRV("AMPE1", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_AMPE, 0, NULL, 0),

	SND_SOC_DAPM_MUX("Amp Input1", SND_SOC_NOPM, 0, 0, &chsa_mux),
	SND_SOC_DAPM_AIF_IN("AIFINL1", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_AIF_IN("AIFINR1", "HiFi Playback", 1, SND_SOC_NOPM, 0, 0),
};

static const struct snd_soc_dapm_route tfa9890_dapm_routes[] = {
	{"OUT1", NULL, "AMPE1"},
	{"AMPE1", NULL, "POWER1"},
	{"AMPE1", NULL, "Amp Input1"},
	{"Amp Input1", "Left", "AIFINL1"},
	{"Amp Input1", "Right", "AIFINR1"},
};

static const struct snd_soc_component_driver tfa989x_component = {
	.probe			= tfa989x_probe,
	.dapm_widgets		= tfa989x_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(tfa989x_dapm_widgets),
	.dapm_routes		= tfa989x_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(tfa989x_dapm_routes),
	.use_pmdown_time	= 1,
	.endianness		= 1,
};
// 第二芯片
static const struct snd_soc_component_driver tfa9890_component = {
	.probe			= tfa989x_probe,
	.dapm_widgets		= tfa9890_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(tfa9890_dapm_widgets),
	.dapm_routes		= tfa9890_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(tfa9890_dapm_routes),
	.use_pmdown_time	= 1,
	.endianness		= 1,
};
const char id = name[13]; //i2c-tfa9890:01 14位=1
	if (id == '0') {
		return devm_snd_soc_register_component(dev, &tfa9890_component,
	 				       					&tfa989x_dai, 1);
	}else{
		return devm_snd_soc_register_component(dev, &tfa989x_component,
	 				       					&tfa989x_dai, 1);
	}
2 个赞

硬件接线上两个tfa9890a的输入输出环接起来了,所以会在选某一声道两个都响。

1 个赞

使用左右声道分别静音的音乐文件,发现左声道两个都响,右声道两个扬声器都没声音
解决了,现在扬声器可以单独处理一个声道

1 个赞

如果你有兴趣把耳机功能也完善的话,可以研究下小米官方源码里\drivers\pinctrl\pinctrl-cherryview.c里部分代码

#define UART_JACK_SW_GPIO 357
#define UART0_RX_GPIO 403
#define UART0_TX_GPIO 408

int chv_enable_jack(int enable)
{
	/* enable/disable jack */
	chv_gpio_cfg_ctrl0(UART_JACK_SW_GPIO, CV_GPIO_TX_STAT,
		enable ? 0 : 1);

	/* Set UART0_DATAOUT */
	chv_gpio_cfg_ctrl0(UART0_TX_GPIO, CV_GPIO_EN, enable);
	if (enable) {
		/* set to low */
		chv_gpio_cfg_ctrl0(UART0_TX_GPIO, CV_GPIO_TX_STAT, 0);
	}
	/* set UART0_DATAIN */
	chv_gpio_cfg_ctrl0(UART0_TX_GPIO, CV_GPIO_EN, enable);
	if (enable) {
		/* set to low */
		chv_gpio_cfg_ctrl0(UART0_TX_GPIO, CV_GPIO_TX_STAT, 0);
	}

	pr_debug("%s %x, %x, %x\n", __func__,
		chv_gpio_cfg_read(UART_JACK_SW_GPIO, CV_PADCTRL0_REG),
		chv_gpio_cfg_read(UART0_TX_GPIO, CV_PADCTRL0_REG),
		chv_gpio_cfg_read(UART0_RX_GPIO, CV_PADCTRL0_REG));
	return 0;
}
EXPORT_SYMBOL_GPL(chv_enable_jack);

里面的gpio引脚号需要按照我上面讲的转换成500以上的。

pinctrl-cherryview.c (39.1 KB)

1 个赞

这部分变动太大了,还涉及内存地址读取。一些api参数换了,如:chv_gpio_reg与新的chv_padreg,还没查到参数struct intel_pinctrl原型

1 个赞

重新看了下电路图,发现那部分代码实际上是驱动一个旁接的uart芯片,应该是小米当初设计了串口来调试用的,并不影响耳机的连通,可以不用管它了。

所以理论上,去对比官方源码里\sound\soc\intel\board\cht_bl_dpcm_rt5672.c与\sound\soc\intel\board\cht_bl_dpcm_rt5659.c的差异,然后把把原版内核里cht_bsw_rt5672.c对应部分更改,并在ucm conf里配置耳机的widget route,应该就可以修复耳机功能了。

2 个赞