Here is a guide to create a kernel from the mainline kernel sources with sound support and several added fixes.
I try to update the guide to reflect recent changes to the kernel. PM me if you think the guide is flawed.
Code:
#STEP 1: Install prerequisites
sudo apt-get update && sudo apt-get install -y build-essential fakeroot libncurses5-dev libssl-dev dialog libelf-dev bc flex bison ### ubuntu/mint/debian/etc.
#or
sudo pacman -Sy --noconfirm wget base-devel ncurses bc dialog openssl ### arch/manjaro/antergos
#or
sudo dnf -y groupinstall "C Development Tools and Libraries" && sudo dnf -y install ncurses-devel elfutils-libelf-devel dialog openssl-devel bc patch ### fedora,etc.
#or
sudo zypper --non-interactive install -t pattern devel_C_C++; sudo zypper --non-interactive in ncurses-devel dialog openssl-devel bc patch ### opensuse
#STEP 2: Download, extract and change directory into source tree:
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.18.5.tar.xz
tar xf linux-4.18.5.tar.xz
cd linux-4.18.5
#STEP 3: Patch the kernel sources:
#patch no. 1 (hide dmesg errors of brcmfmac trying to enable a p2p device)
(run 'patch -p1 --dry-run < name-of.patch' on every patch first to see if the patch will be applied without errors)
wget https://raw.githubusercontent.com/harryharryharry/x205ta-patches/master/4.18-patches/brcmfmac-p2p-and-normal-ap-access-are-not-always-possible-at-the-same-time.patch
patch -p1 < brcmfmac-p2p-and-normal-ap-access-are-not-always-possible-at-the-same-time.patch
#patches no. 2 and 3 (attempts to prevent baytrail related c-state freezes; by Hans de Goede)
wget https://raw.githubusercontent.com/harryharryharry/x205ta-patches/master/4.18-patches/i915-pm-Be-less-agressive-with-clockfreq-changes-on-Bay-Trail.patch
patch -p1 < i915-pm-Be-less-agressive-with-clockfreq-changes-on-Bay-Trail.patch
wget https://raw.githubusercontent.com/harryharryharry/x205ta-patches/master/4.18-patches/intel_idle-Disable-C6N-and-C6S-on-Bay-Trail.patch
patch -p1 < intel_idle-Disable-C6N-and-C6S-on-Bay-Trail.patch
#patch no. 4 (optional; adds headphones support which can also be done using a config file)
wget https://raw.githubusercontent.com/harryharryharry/x205ta-patches/master/4.18-patches/ASoC-rt5645-add-quirk-for-ASUS-EeeBook-X205TA-4.17.patch
patch -p1 < ASoC-rt5645-add-quirk-for-ASUS-EeeBook-X205TA-4.17.patch
#or add:
options snd_soc_rt5645 quirk=0x31
blacklist snd_hdmi_lpe_audio #(only necessary if this module is built, but better safe than sorry)
blacklist btsdio #(not necessary for headphones support, but this module breaks wifi during suspend on the x205ta so it makes sense to blacklist it here anyway)
#to /etc/modprobe.d/50-x205ta.conf
#source for quirk: https://bugzilla.kernel.org/show_bug.cgi?id=95681#c243
#source for blacklisting snd_hdmi_lpe_audio: https://bugzilla.kernel.org/show_bug.cgi?id=95681#c218
#STEP 4: configure, compile and install the kernel
#configure
make localmodconfig ### make minimal kernel config base on currently booted kernel
make menuconfig ### to change kernel configuration (optional)
#compile - this will take a while
make -j6
#install kernel modules to /lib/modules
sudo make modules_install
#optionally install kernel headers
sudo make headers_install
#set variable KERNELRELEASE as kernelversion to use when installing kernel and initramfs
export KERNELRELEASE=$(<include/config/kernel.release)
#copy kernel to /boot
sudo cp -va arch/x86/boot/bzImage /boot/vmlinuz-$KERNELRELEASE
#generate initramfs to /boot
sudo update-initramfs -c -k $KERNELRELEASE ### ubuntu/mint/debian/etc.
#or
sudo mkinitcpio -k $KERNELRELEASE -c /etc/mkinitcpio.conf -g /boot/initramfs-$KERNELRELEASE.img ### arch/manjaro/antergos
#or
sudo dracut -fv /boot/initramfs-$KERNELRELEASE.img $KERNELRELEASE ### fedora,etc.
#rebuild grub
from 4.15-rc6 on, the linux kernel includes a patch to address the recently discovered Meltdown vulnerability which
makes the kernel safer but also degrades its performance by quite a bit. I would advise you to accept this performance degradation,
but if you prefer performance over safety you can disable the page table isolation (pti) by adding the kernel parameter pti=off to /etc/default/grub :
(between the quotes after GRUB_CMDLINE_LINUX_DEFAULT) before (re)generating grub.cfg
sudo update-grub ### ubuntu/mint/debian/etc.
#or
sudo grub-mkconfig -o /boot/grub/grub.cfg ### arch/manjaro/antergos
#or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg ### fedora,etc.
#download UCM-files to /usr/share/alsa/ucm/chtrt5645
sudo rm -rf /usr/share/alsa/ucm/chtrt5645/{HiFi,chtrt5645}.conf
sudo mkdir -p /usr/share/alsa/ucm/chtrt5645
sudo wget https://raw.githubusercontent.com/harryharryharry/x205ta-iso2usb-files/master/HiFi.conf -O /usr/share/alsa/ucm/chtrt5645/HiFi.conf
sudo wget https://raw.githubusercontent.com/plbossart/UCM/master/chtrt5645/chtrt5645.conf -O /usr/share/alsa/ucm/chtrt5645/chtrt5645.conf
#STEP 5: install pavucontrol (optional) to change sound output (headphone jack detection does not work yet)
sudo apt-get install -y pavucontrol ### ubuntu/mint/debian/etc. (debian also needs the package firmware-intel-sound which is in the non-free repository)
#or
sudo pacman -Sy --noconfirm pavucontrol ### arch/manjaro/antergos
#or
sudo dnf -y install pavucontrol ### fedora,etc.
#STEP 6: reboot and select the kernel during boot
#STEP 7: run 'pavucontrol' and select 'speakers' instead of 'headphones'
Bookmarks