Bug 197073 - soundcard not recognised - ES8316
Summary: soundcard not recognised - ES8316
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: Intel Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-29 12:58 UTC by eric.alemany@stim.fr
Modified: 2017-12-13 21:17 UTC (History)
4 users (show)

See Also:
Kernel Version: 4.13.0
Subsystem:
Regression: No
Bisected commit-id:


Attachments
dmesg (41.12 KB, text/plain)
2017-09-29 12:58 UTC, eric.alemany@stim.fr
Details
config kernel 4.13 (147.42 KB, text/x-mpsub)
2017-09-29 12:59 UTC, eric.alemany@stim.fr
Details
alsa-info (3.38 KB, text/plain)
2017-09-29 13:00 UTC, eric.alemany@stim.fr
Details
dsdt (1.03 MB, text/x-csrc)
2017-09-29 13:01 UTC, eric.alemany@stim.fr
Details
alsa-info with acpi infos (10.71 KB, text/plain)
2017-11-21 08:47 UTC, eric.alemany@stim.fr
Details
alsa-info with acpi infos (better) (10.75 KB, text/plain)
2017-11-21 08:59 UTC, eric.alemany@stim.fr
Details

Description eric.alemany@stim.fr 2017-09-29 12:58:34 UTC
Created attachment 258631 [details]
dmesg

Pipo X9S - ( Cherry-trail tablet) soundcard not recognised - ES8316
Comment 1 eric.alemany@stim.fr 2017-09-29 12:59:51 UTC
Created attachment 258633 [details]
config kernel 4.13
Comment 2 eric.alemany@stim.fr 2017-09-29 13:00:21 UTC
Created attachment 258635 [details]
alsa-info
Comment 3 eric.alemany@stim.fr 2017-09-29 13:01:09 UTC
Created attachment 258637 [details]
dsdt
Comment 4 eric.alemany@stim.fr 2017-09-29 13:05:43 UTC
 I installed a linux system on cherry-Trail tablets "Pipo X9S" (purchased with Android+Windows 10)
Sound works well with Android and Windows 10, but i wasn't able to use it (without hdmi) for months. So after exploring multiples patches and kernels (last one 4.13) i decided to ask community for a little help. 

On theses machines, driver "snd-intel-sst-acpi" recognizes the device 808622A8 and so use sst_acpi_chv structure to match various acpi eventuals HIDs: 10EC5670,10EC5672...10EC5651,and 808622A8(for bytcht_nocodec).
But with these Pipo X9S Z8350 tablets, there are 2 HID values for audio found in DSDT table (section "Device (I2C2)"):
 - Device (RTEK) 10EC5640:00
 - Device (RTK2) 10EC5645:00
But both have a zero status in  /sys/bus/acpi/devices/.../status so no drivers works and so no /proc/asound/cards
 
I also looked for HID ESSX8316 because a sound component with that name is present on the board, and windows use a ESX8316 driver related to HID ESX8316, (Android uses driver cht_es8316) but still zéro status in ACPI...
I also checked all devices ons /sys/bus/acpi/ with status 1. But nothing seems sound related.
 
On Android many drivers are loaded, but i wonder how did they use intel_sst_acpi with cht_es8316?
As i saw these error messages in android console, i think there are workarounds to make sound working:
> <3>[    2.456005] snd_intel_sst: board_name:Cherry Trail CR
> <6>[    2.461732] snd_intel_sst: Registering machine device cht_es8316
> <3>[    2.462314] snd_intel_sst: Requesting FW fw_sst_22a8.bin now...
> <4>[    2.469049] intel_sst_acpi 808622A8:00: Direct firmware load failed
> with error -2
> <4>[    2.477459] intel_sst_acpi 808622A8:00: Falling back to user helper
> ...
> <3>[    5.228018] cht_es8316 cht_es8316: ASoC: CPU DAI Headset-cpu-dai not
> registered
> <3>[    5.236395] snd_soc_register_card failed -517
> ...
> <6>[    5.461398] cht_es8316 cht_es8316: snd-soc-dummy-dai <->
> snd-soc-dummy-dai mapping ok
> <3>[    5.461848] cht_es8316 cht_es8316: ASoC: Failed to add Headphone
> Switch: -16


thanks
Comment 5 eric.alemany@stim.fr 2017-10-06 11:35:20 UTC
in Windows , device manager seems sound is using 808622A8 and ESSX8316 :

sound, video and game controllers:
	- ES8316AudCodec device
		on intel serial IO i2c ES controller
		hardware lds:	ACPI\VEN_ESSX&DEV_8316
				ACPI\ESSX8316
		inf section : ESX9316AudioCodec_Device
		Matching device Id: acpi\essx8316
		Bios device name: \_SB PCI0 I2C2 ESSX
		bus number 0 
		device 000066

	- intel SST Audio Device (WDM)
		Matching device Id: acpi\808622a8
		Bios device name: \_SB PCI0 LPEA
		device 00003a
Comment 6 Pierre Bossart 2017-10-06 16:41:57 UTC
This should work out of the box, not sure why you have issues with the platform driver.
Comment 7 eric.alemany@stim.fr 2017-11-17 08:09:32 UTC
still none progress with this hard... 

The main thing I don't understand is why snd-soc-sst-byt-cht-es8316.ko driver would be used, as ACPI status of ESSX8316:00 is zero?


( in sst_acpi.c , i understand that sst_acpi_chv structure do an "ACPI match" to many devices like ESSX8316, 10EC5670... but none have a status to 15 !)



#########
a bit more infos:

/sys/bus/acpi/devices/ESSX8316:00  is a link to ../../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/808622C1:01/ESSX8316:00 with status 0

( 808622C1 ACPI status is set to 15 , sothe driver i2c-designware-platform loaded, and gives i2c-0 - i2c-6 busses )
Comment 8 Pierre Bossart 2017-11-17 14:56:00 UTC
[    3.249950] intel_sst_acpi 808622A8:00: Direct firmware load for intel/fw_sst_22a8.bin failed with error

-> did you install the firmware files in /lib/firmware/intel?
Comment 9 Pierre Bossart 2017-11-17 14:58:13 UTC
also can you run a newer version of alas-info.sh which dumps all ACPI status, the one you provided gives next to zero information.
Comment 10 eric.alemany@stim.fr 2017-11-21 08:47:56 UTC
Created attachment 260757 [details]
alsa-info with acpi infos

alsa-info with acpi infos
Comment 11 eric.alemany@stim.fr 2017-11-21 08:52:14 UTC
firmware ok:
ls -l /lib/firmware/intel/
-rwxr-xr-x    1 root     root        701622 Nov 21 09:05 fw_sst_0f28.bin
-rwxr-xr-x    1 root     root        265684 Nov 21 09:05 fw_sst_0f28.bin-48kHz_i2s_master
-rwxr-xr-x    1 root     root        701622 Nov 21 09:05 fw_sst_0f28_ssp0.bin
-rwxr-xr-x    1 root     root        701694 Nov 21 09:05 fw_sst_22a8.bin


Always msg "intel_sst_acpi 808622A8:00: No matching machine driver found"
Comment 12 eric.alemany@stim.fr 2017-11-21 08:59:38 UTC
Created attachment 260759 [details]
alsa-info with acpi infos (better)


Forgot to load snd-soc-es8316.ko and snd-soc-sst-byt-cht-es8316.ko, so i did another "alsa-info.sh". 
But nothing more in dmesg
Comment 13 Pierre Bossart 2017-11-21 16:37:05 UTC
Something's very odd in your config. You don't have the ESSX8316 in alas-info.sh but it's part of the DSDT...

Can you check by hand in /sys/bus/acpi/devices/ESSX8316*/status?

Same for the *TIMC stuff, this is supposed to be a TI codec and I don't get why it's set to 15.
Comment 14 eric.alemany@stim.fr 2017-11-22 07:59:16 UTC
cat /sys/bus/acpi/devices/ESSX8316*/status : 0

For  TIMC22A8\:00 status is 15.



----
comment:
Just in case (i look now for weeks for this problem) i've previously tried patching snd-intel-sst-acpi driver :
.id = "ESSX8316", with various id devices, and in particular with .id = "TIMC22A8" , in sst_acpi.c .

But obviously nothing special except as expected this lines  :
[  367.448432] intel_sst_acpi 808622A8:00: LPE base: 0x91400000 size:0x200000
[  367.448439] intel_sst_acpi 808622A8:00: IRAM base: 0x914c0000
[  367.448478] intel_sst_acpi 808622A8:00: DRAM base: 0x91500000
[  367.448488] intel_sst_acpi 808622A8:00: SHIM base: 0x91540000
[  367.448514] intel_sst_acpi 808622A8:00: Mailbox base: 0x91544000
[  367.448523] intel_sst_acpi 808622A8:00: DDR base: 0x20000000
[  367.448606] intel_sst_acpi 808622A8:00: Got drv data max stream 25

and later, inserting snd-soc-sst-byt-cht-es8316.ko : 
[ 2364.094176] bytcht_es8316 bytcht_es8316: ASoC: CODEC DAI ES8316 HiFi not registered
[ 2364.094189] bytcht_es8316 bytcht_es8316: snd_soc_register_card failed -517


i know it's a bit sorcers's apprentice but i'm bloqued
Comment 15 eric.alemany@stim.fr 2017-11-24 15:00:37 UTC
More infos:

On linux, i think the the i2c_designware busses number 1 is used for sound because :
ls -l   /sys/bus/acpi/devices/808622C1\:01/ gives :
drwxr-xr-x    4 root     root             0 Nov 24 14:35 10EC5640:00
drwxr-xr-x    4 root     root             0 Nov 24 14:35 10EC5645:00
drwxr-xr-x    4 root     root             0 Nov 24 14:35 ESSX8316:00
drwxr-xr-x    3 root     root             0 Nov 24 14:35 IMPJ0003:01
drwxr-xr-x    3 root     root             0 Nov 24 14:35 LNXPOWER:0f
drwxr-xr-x    3 root     root             0 Nov 24 14:35 LNXPOWER:10
-r--r--r--    1 root     root          4096 Nov 24 14:35 hid
-r--r--r--    1 root     root          4096 Nov 24 14:35 modalias
-r--r--r--    1 root     root          4096 Nov 24 14:35 path
lrwxrwxrwx    1 root     root             0 Nov 24 14:35 physical_node -> ../../../../pci0000:00/808622C1:01
lrwxrwxrwx    1 root     root             0 Nov 24 14:35 physical_node1 -> ../../../../pci0000:00/808622C1:01/i2c-1
drwxr-xr-x    2 root     root             0 Nov 24 14:35 power
-r--r--r--    1 root     root          4096 Nov 24 14:35 power_state
-r--r--r--    1 root     root          4096 Nov 24 14:35 status
lrwxrwxrwx    1 root     root             0 Nov 24 14:35 subsystem -> ../../../../../bus/acpi
-rw-r--r--    1 root     root          4096 Nov 24 14:35 uevent
-r--r--r--    1 root     root          4096 Nov 24 14:35 uid


When i scan this bus "1", with "i2cdetect -r 1" , i see on this bus a chip at address 0x11 with no drivers assigned. 


***
Remark:
 to try to understand, i compared with an old baytrail chipset, the "Pipo X9" , not this cherry-trail "Pipo X9S", with sound working. The same work gives for that  baytrail , on a i2c designware bus, an address 0x1c assigned to driver snd_soc_rt5640, with sound OK . And i saw the chip witch had a status of 15 , 10EC5640:00, in /sys/bus/acpi/devices/80860F41\:01/
So, this that status of 15, the driver snd_soc_sst_bytcr_rt5640 was used by snd-intel-sst-acpi and it worked .
***


I tried, like that "old" baytrail tablet , to insert many codec drivers (witch  don't need /sound/soc/intel/boards/ drivers) , but none seems tu use the chip at address 0x11 (still not in "UU" state with i2cdetect)

So i wonder why ESX8316 is at status of zero. Is it possible it works without acpi ?
Comment 16 eric.alemany@stim.fr 2017-11-24 15:06:01 UTC
second more info, booting with Android:


The sound works in android, and i collected a few info in a terminal:

* the acpi status are same values as linux for all acpi devices in /sys/bus/acpi/devices (i checked for 808622C1*, ESX* (=0), TIMC22A8* (=1) ...)


* the name of google driver in /proc/asound/cards is "cherrytailaud"

* in live dmesg i saw from time to time a reference to "codec name es8316.1-0011"




So i wonder how did google use this everest chip, because it seems to use a esx8316 codec but without that acpi status OK too ...
Comment 17 eric.alemany@stim.fr 2017-11-24 15:06:42 UTC
TIMC22A8* (=15)
Comment 18 Pierre Bossart 2017-11-27 14:35:44 UTC
So you don't have an ESS chip, it's a TI chip on your platform, so something is not working in the machine driver selection and we are also missing the upstream version of  the machine/codec driver...
Comment 19 Pierre Bossart 2017-11-27 16:28:33 UTC
It could also be that there is something specific for Windows, clearly there is a variable name which changes the status reported to the OS. The only explanation for what you found is that this OSID value is changed somehow and that the same DSDT was intended to be used for different hardware platforms, but if you try to install Linux/Android on a Windows-based design then the results are just plain wrong.

ESSX

                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If (LEqual (OSID, One))
                    {
                        Return (0x0F)
                    }
                    Else
                    {
                        Return (Zero)
                    }
                }


TIMC

	Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                If (LAnd (LNotEqual (OSID, One), LEqual (BDID, One)))
                {
                    Return (0x0F)
                }

                Return (Zero)
            }
Comment 20 eric.alemany@stim.fr 2017-11-28 13:00:44 UTC
we checked inside the pipo box: it's an Everest es8316 chip, it's written on the soc.

We "i2cdump" the content of chip at address 0x11, Designware bus 1, and we found the registers values corresponding to the everest ES8316 default ones in the datasheet.
Comment 21 Pierre Bossart 2017-11-28 14:28:27 UTC
ok, so it looks like a BIOS issue. I'll try to ask folks if there is a way to tweak this, but in the mean time the 'easy fix' is to override the DSDT so that the _STA returns 0xF for the ESSX device and 0 for the TIMC, just remove all the conditional parts.
Comment 22 eric.alemany@stim.fr 2017-11-28 16:06:48 UTC
You were right. 
I first tried patching dsdt to get a 15 status. It worked for this status, but i have many issues due to my poor knowlegde with dsdt patching (marking kernel as "standalone" to insert a custom dsdt brings issues with many drivers)

Than, i discover ( it's a dual boot Windows/Android machine) that if i choose first to boot with windows, the machine restart and than boot on my linux key with a correct status for ESX8316 !

Thanks for pointing me the crucial DSDT part in comment 15 . 
snd-soc-sst-byt-cht-es8316.ko creates the/proc/asound/cards !


Just now, only "writing to lpe" in dmesg with no sound, but it's another problem.

So i have :
- to manage defitively my bios/acpi (booting first windows is not a good way for us, as we erase the internal mmc with linux) 
- and find the correct soft to get sound (ucm files, or other drivers (i2s?))
but it's a great step ahead to make a es8316 status ok

I'll come back here when i'll find remaining issues


thanks
Comment 23 eric.alemany@stim.fr 2017-12-06 15:39:36 UTC
modifing dsdt definitively dit it! But i had to add a patch for speakers:




**** DSDT :

Patching dsdt made the job to return 0x15:

ESSX

                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If (LEqual (OSID, One))
                    {
                        Return (0x0F)
                    }
                    Else
                    {
                        Return (0x0F)
                    }
                }


**** speakers :
The sound on headphones was OK with esx8316 drivers in 4.14.1, but not for speakers.

I read that switching SPK/HP is done externally with gpio. So i had to add additionnal code to es8316.c to manipulate gpio. I found a similar patch for Chuwi Hi12 that worked for me:
at https://abf.io/st/kernel-tablet-4.13/commit/3d8b602414ef9d490780bc189eb6c5c2348e32ff 

( I applied only the first patch : es8316-Audio-exported-gpio-controlling-SPK-analog-switch.patch , discardind control by dmi_check_system )

That created for my tablet a new gpio to enable speakers.

echo 1 >  /sys/class/gpio/gpio386/value
and know speakers and headphones are OK

thanks for you help
Comment 24 Pierre Bossart 2017-12-06 20:15:58 UTC
Good that you have a solution
unfortunately the patch you are referring to doesn't have a signed-off-by so can't touch it and take it upstream...

Note You need to log in before you can comment on or make changes to this bug.