John-Hsu / Nuvoton

Nuvoton Audio Chip
6 stars 1 forks source link

Isn't there a driver for Cherry Trail with NAU88L25 codec? #2

Open initguru opened 4 years ago

initguru commented 4 years ago

Dear John-Hsu, I saw your signature inside snd-soc-nau8825 header file so that I'm contacting you here.

I have been looking for a method how to enable audio output to a headset on Asus VivoStick TS10 with Cherry Trail Atom X5-Z8350 + NAU88L25 audio codec. I have tried up to the latest linux kernel 5.4.x and it still does not work. By compiling a kernel with every Baytrail / Cherrytrail specific drivers enabled, eventually bytcht-nocodec is loaded because no driver for ACPI id 10508825.

I can only see the driver for Bay Trail + NAU88L24 for linux 4.xx here but not NAU88L25. Please let me know if there is a support for this audio codec in linux.

dmesg: https://paste.ubuntu.com/p/7kxmtbcywb/ lsmod: https://paste.ubuntu.com/p/Cv7NdfzzpH/ lspci: https://paste.ubuntu.com/p/SzkTg8yjQ6/

John-Hsu commented 4 years ago

Hi Initguru, I think you need a machine driver of Cherry Trail for NAU88L25, but unfortunately, we don't have this machine driver now. We only provide the NAU88L24 machine driver in Cherry Trail.

The machine drivers of these two chips are very similar. I guess it's not difficult to copy the nau8825 machine driver from nau8824. But what I worry about is that we don't have a platform for testing the machine driver, and our development resources are too few to build a development system for the nau8825 machine.

If you really want to enable the solution, we can only provide the source code to you, but you have to verify it yourself. What do think?

initguru commented 4 years ago

Thanks for the reply. Yes, what I meant was a machine driver and as you said I thought nau8824 and nau8825 should be similar. I copied cht_bsw_nau8824 ASoC machine driver as cht_bsw_nau8825 and added just a few lines. Compiling a kernel was done without errors and I'm going to test tonight. I'm not quite sure if it works or not though because it was done by just copy and paste. I will share a result here. By the way it would be great if you can provide the source code for reference.

John-Hsu commented 4 years ago

I don't know what kernel version you are using. Maybe you can refer to the following link for other related files. Please search for keywords related to nau8824. https://github.com/John-Hsu/Nuvoton/tree/master/NAU88L24/Intel-cht-bsw

initguru commented 4 years ago

A kernel is 4.19.x and I can see your repository has 4.15.x source, I think it is not different so much!

initguru commented 4 years ago

A new module loaded but showed the error as below:

[  325.938464] cht-bsw-nau8825 cht-bsw-nau8825: snd-soc-dummy-dai <-> media-cpu-dai mapping ok
[  325.938753] cht-bsw-nau8825 cht-bsw-nau8825: snd-soc-dummy-dai <-> deepbuffer-cpu-dai mapping ok
[  325.938975] cht-bsw-nau8825 cht-bsw-nau8825: Compress ASoC: snd-soc-dummy-dai <-> compress-cpu-dai mapping ok
[  325.939956] (NULL device *): can't set codec TDM slot -524
[  325.940379] cht-bsw-nau8825 cht-bsw-nau8825: ASoC: failed to init SSP2-Codec: -524
[  325.940578] cht-bsw-nau8825 cht-bsw-nau8825: ASoC: failed to instantiate card -524
[  325.944859] cht-bsw-nau8825 cht-bsw-nau8825: snd_soc_register_card failed -524
[  325.945045] cht-bsw-nau8825: probe of cht-bsw-nau8825 failed with error -524

I do not know what TDM is but as in skl_nau88l25_max98357a.c in 4.19.x kernel for nau8825 reference it seems snd_soc_dai_set_tdm_slot is not used.. Would you please confirm if I can remove those lines in a machine driver for nau8825?

    /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
    ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0x1, 4, 24);
    if (ret < 0) {
        dev_err(runtime->dev, "can't set codec TDM slot %d\n", ret);
        return ret;
    }
John-Hsu commented 4 years ago

The error occurs because nau8825 wants to enable TDM, but it doesn't have the TDM function actually.

Please refer to the files which I just check-in. https://github.com/John-Hsu/Nuvoton/tree/master/NAU88L25/Intel-cht-bsw/kernel-4.19

I worry about the sof tplg file after I check the intel machine files. There is a file sof-cht-nau8824.tplg for nau8824. But nau8825 doesn't have this file. Therefore, I use the nau8824 file currently. I need to study it.

Please attach the complete log if you encounter errors. Thank you.

initguru commented 4 years ago

Thx for uploading the whole files needed. I will merge them into a kernel tree and test again. Also, as you already said, there is no sof topology file for nau8825. My device is too old to get any support and there is just a few people using it.

John-Hsu commented 4 years ago

I also put the patch here for your reference.

Cherrytrail_nau8825_machine_patch.zip

initguru commented 4 years ago

Tested an updated kernel, I have this log: https://paste.ubuntu.com/p/TSHpj5MQ9F/

It seems the module loaded and the machine/codec driver initialized. (headphone jack is not yet tested, didn't have time)

Can you please look at the log if there is something which needs to fix further?

John-Hsu commented 4 years ago

I consider the nau8825 sound card has been created. You can check the card by the following command. $ aplay -l

In the log, I find there is a detection error. [ 247.083838] nau8825 i2c-10508825:00: detection error; disable mic function [ 247.092585] nau8825 i2c-10508825:00: 11 <= 400 I'm not sure if the problem is caused by the sucket or headphone itself. You can plug and unplug the headphone several times and check the log for the issue.

You also need to do one thing in Ubuntu OS. Please put the folder chtnau8825 into your file system /usr/share/alsa/ucm/. https://github.com/John-Hsu/Nuvoton/tree/master/NAU88L25/Intel-cht-bsw/ucm/chtnau8825 Thus, you will see the following UCM configs in the following path. /usr/share/alsa/ucm/chtnau8825/HiFi.conf /usr/share/alsa/ucm/chtnau8825/chtnau8825.conf

John-Hsu commented 4 years ago

One more thing, I chang the headphone jack name. Please sync the file chtnau8825.c. https://github.com/John-Hsu/Nuvoton/commit/e588b265c6db5880684c337280f05c3d41d68803

initguru commented 4 years ago

Thanks, I'm going to sync chtnau8825.c and put related ucm files then test again.

initguru commented 4 years ago

I forgot to say one more thing, would you please check in cht-bsw-nau8824.tplg file also? I searched the file in linux firmware binaries and it is not there.

CTLIN0 commented 4 years ago

@initguru From your log, you use old audio architecture and it is based on sst driver. So far, dsp firmware(fw_sst_22a8.bin) is loaded, you need to configure your ucm first. if you use new audio architecture which is based on sof, you'll need tplg file.

initguru commented 4 years ago

@CTLIN0 Thanks for the info, as you said I was curious why there is no sof related logs. Now it's clear the device does not need the topology file. I already put ucm files and let's see how it goes.