Skip to content

Commit

Permalink
Add cx2072x readme and updated manual
Browse files Browse the repository at this point in the history
  • Loading branch information
heikomat committed May 22, 2019
1 parent 95f27de commit 421d558
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 0 deletions.
94 changes: 94 additions & 0 deletions cx2072x_fixes_and_manual/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Make audio work on cx2072x devices like the Asus E200HA

## TL;DR

**If You're on Debian or Ubuntu, run this (at your own risk!!)**
```bash
wget -qO- https://gist.github.com/heikomat/3fe272431b44b580c933bfb901a92257/raw | bash
```

## General sound setup:

Most of the following information are from these sources:

- [Kernel Bug #115531](https://bugzilla.kernel.org/show_bug.cgi?id=115531)
- [Repository with the Fixes for an older kernel](https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git)
- [Asus E200HA fix-script-Repo by Grippentech](https://github.com/Grippentech/Asus-E200HA-Linux-Post-Install-Script)

This manual is for debain and derivates of it, though it can ~~probably~~definitely be adapted
for other linux systems (see [here](https://github.com/Grippy98/Asus-E200HA-Linux-Post-Install-Script/issues/30#issuecomment-404034681)). Debian and Ubuntu users can use the [script provided](https://gist.github.com/heikomat/3fe272431b44b580c933bfb901a92257)
above. Its goal is to do the steps described here:

1. Get the Kernel with the cx2072x codec driver and the cx2072x machine driver from [releases](https://github.com/heikomat/linux/releases), or build it yourself (see [building the kernel](building_the_kernel.md#building-the-kernel))

This tells the Linux how to talk to the hardware.

1. Install the kernel
```
sudo dpkg --install LINUX_IMAGE_DEB_PACKAGE.deb
sudo dpkg --install LINUX_HEADERS_DEB_PACKAGE.deb
```

1. Have `pulseaudio` installed
```bash
sudo apt install pulseaudio
```

1. Have [`firmware-intel-sound`](https://packages.debian.org/buster/firmware-intel-sound)
(for debian) or [`linux-firmware`](https://packages.ubuntu.com/de/artful/linux-firmware)
(for ubuntu) installed.

This contains the firmware for intels sst audio device (`/lib/firmware/intel/fw_sst_22a8.bin`).
The firmware is the proprietary software that runs within the chip.
```bash
# debian
sudo apt install firmware-intel-sound

# ubuntu
sudo apt install linux-firmware
```

1. Copy the configuration files for alsa (`bytcht-cx2072x.conf` and `HiFi.conf` from
the [bytcht-cx2072x folder](https://github.com/heikomat/linux/tree/cx2072x/cx2072x_fixes_and_manual/bytcht-cx2072x))
to `/usr/share/alsa/ucm/bytcht-cx2072x` (creating the folder first).

These tell alsa what driver and codec to use, and how to use them

```bash
sudo mkdir --parents /usr/share/alsa/ucm/bytcht-cx2072x
cd /usr/share/alsa/ucm/bytcht-cx2072x
sudo wget "https://raw.githubusercontent.com/heikomat/linux/cx2072x/cx2072x_fixes_and_manual/bytcht-cx2072x/HiFi.conf"
sudo wget "https://raw.githubusercontent.com/heikomat/linux/cx2072x/cx2072x_fixes_and_manual/bytcht-cx2072x/bytcht-cx2072x.conf"
```
1. Set `realtime-scheduling = no` in `/etc/pulse/daemon.conf` (_see [this issue-comment](https://github.com/Grippentech/Asus-E200HA-Linux-Post-Install-Script/issues/29#issuecomment-355113121)_).

This makes the pulseaudio daemon not die if the audio device is not found instantly

**via script**
```bash
sudo sed --in-place --regexp-extended --expression='s/;?\s*realtime-scheduling\s*=\s*(yes|no)/realtime-scheduling = no/g' /etc/pulse/daemon.conf
```

**by hand**
1. Make sure you edit the file as root, for example with `sudo nano /etc/pulse/daemon.conf`
1. Change `; realtime-scheduling = yes` to `realtime-scheduling = no`
1. **make sure you removed the `;` at the beginning of the line, this is important!**
1. Reboot

## Possible fixes if audio is still not working:
- Remove possibly existing user-pulse-config with `rm -rf ~/.config/pulse/*`
- Set pulseaudios default device:
1. Check wich index your non-hdmi audio device has with `pactl list short sinks`
1. `pacmd set-default-sink 1` (replacing the 1 with the audio-device-index)

## Getting a detailed pulseaudio log, for when debugging is necessary
1. Enable debug-messages for pulseaudio by editing `/etc/pulse/daemon.conf`
1. Make sure you edit the file as root, for example with `sudo nano /etc/pulse/daemon.conf`
1. Change `; log-level = notice` to `log-level = debug`
1. **make sure you removed the `;` at the beginning of the line, this is important!**
1. Reboot
1. Put a log on the Desktop with
```bash
sudo cat /var/log/syslog | grep 'intel\|cx2072x\|pulse\|alsa\|cht\|byt\|error' > ~/Desktop/pulselog.txt
```
1. Give use the pulselog.txt you now have on your Desktop
47 changes: 47 additions & 0 deletions cx2072x_fixes_and_manual/building_the_kernel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Building the kernel

## Some base info

- This Kernel ist based on the current `topic/soc-cx2072x`-branch from [here](https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git?h=topic%2Fsoc-cx2072x-5.1) (`topic/soc-cx2072x-5.1` at the time of writing this)
- I added (and updated) alsa ucm files mentioned in [this](https://bugzilla.kernel.org/show_bug.cgi?id=115531#c41) bugreport (Thank you [@roethigj](https://github.com/roethigj) for [informing me](https://github.com/heikomat/linux/issues/8#issuecomment-493793106) about takashis updated patches and the required adjustments to the ucm files!)
- These instructions are written for debian, but they do work on ubuntu and this kernel has also been successfully build for arch (see [here](https://github.com/Grippy98/Asus-E200HA-Linux-Post-Install-Script/issues/30#issuecomment-404034681))

## Building in a Docker container

There is a branch with a dockerfile to build the debian/ubuntu packages for this kernel. I added it so i can build the kernel on macOS, so i don't have to dualboot.

See [this build-script](https://github.com/heikomat/linux/blob/dockerized_deb_build/build.sh), which uses [this Dockerfile](https://github.com/heikomat/linux/blob/dockerized_deb_build/Dockerfile), both from [this branch](https://github.com/heikomat/linux/tree/dockerized_deb_build)

Be prepared for the docker image to get about 27GB in size. As you can see in the Dockerfile, it builds in an ubuntu container by pulling from the cx2072x-branch. you might want to adjust the number of threads used.

## Building the conventional way

### Prerequesites

You need to have the following packages installed:
```
git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc kernel-package
```

### Configuring

- Copy a base config: `cp -v /boot/config-$(uname -r) .config`
- Run `make menuconfig`
- Enable these configurations:
- ```
Device Drivers -> Sound card support -> Advanced Linux Sound Architecture -> ALSA for SoC audio support -> CODEC drivers -> Conexant CX2072 CODEC
```
- ```
Device Drivers -> Sound card support -> Advanced Linux Sound Architecture -> ALSA for SoC audio support -> Intel ASoC SST drivers -> Intel Machine drivers > Baytrail and Cherrytrail with CX2072X codec
```
- Remove the string in this configuration:
- ```
Cryptographic API -> Certificates for signature checking -> Provide system-wide ring of trusted keys -> Additional X.509 keys for default system keyring
```
### Building
replace the `8` with the number of cores in your system and run:
```
make deb-pkg -j 8
```
185 changes: 185 additions & 0 deletions cx2072x_fixes_and_manual/bytcht-cx2072x/HiFi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
SectionVerb {
# ALSA PCM
Value {
TQ "HiFi"

# ALSA PCM device for HiFi
PlaybackPCM "hw:bytchtcx2072x,0"
CapturePCM "hw:bytchtcx2072x,0"
}

EnableSequence [
cdev "hw:bytchtcx2072x"

# Enable audio output path
cset "name='codec_out0 mix 0 pcm0_in Switch' on"
cset "name='media0_out mix 0 media1_in Switch' on"

cset "name='media1_in Gain 0 Ramp Delay' 50"
cset "name='media1_in Gain 0 Switch' on"
cset "name='media1_in Gain 0 Volume' 0dB"

cset "name='pcm0_in Gain 0 Ramp Delay' 50"
cset "name='pcm0_in Gain 0 Switch' on"
cset "name='pcm0_in Gain 0 Volume' 0dB"

cset "name='codec_out0 Gain 0 Ramp Delay' 50"
cset "name='codec_out0 Gain 0 Switch' on"
cset "name='codec_out0 Gain 0 Volume' 0dB"

# Enable audio input path
cset "name='pcm1_out mix 0 media_loop2_in Switch' on"
cset "name='media_loop2_out mix 0 codec_in0 Switch' on"

cset "name='codec_in0 Gain 0 Ramp Delay' 50"
cset "name='codec_in0 Gain 0 Switch' on"
cset "name='codec_in0 Gain 0 Volume' 0dB"

cset "name='media_loop2_out Gain 0 Ramp Delay' 50"
cset "name='media_loop2_out Gain 0 Switch' on"
cset "name='media_loop2_out Gain 0 Volume' 0dB"

cset "name='pcm1_out Gain 0 Ramp Delay' 50"
cset "name='pcm1_out Gain 0 Switch' on"
cset "name='pcm1_out Gain 0 Volume' 0dB"

# Output Configuration
cset "name='I2S DAC1L Switch' on"
cset "name='I2S DAC1R Switch' on"

# Input Configuration
cset "name='I2S ADC1L Switch' on"
cset "name='I2S ADC1R Switch' on"
]

DisableSequence [
cdev "hw:bytchtcx2072x"

# Disable audio output path
cset "name='codec_out0 mix 0 pcm0_in Switch' off"
cset "name='media0_out mix 0 media1_in Switch' off"

cset "name='media1_in Gain 0 Switch' off"
cset "name='pcm0_in Gain 0 Switch' off"
cset "name='codec_out0 Gain 0 Switch' off"

# Disable audio input path
cset "name='pcm1_out mix 0 media_loop2_in Switch' off"
cset "name='media_loop2_out mix 0 codec_in0 Switch' off"

cset "name='media_loop2_out Gain 0 Switch' off"
cset "name='pcm1_out Gain 0 Switch' off"
cset "name='codec_in0 Gain 0 Switch' off"

# Output Configuration
cset "name='I2S DAC1L Switch' off"
cset "name='I2S DAC1R Switch' off"

# Input Configuration
cset "name='I2S ADC1L Switch' off"
cset "name='I2S ADC1R Switch' off"
]
}

SectionDevice."Speaker" {
Comment "Speaker"

Value {
PlaybackChannels "2"
}

ConflictingDevice [
"Headphone"
]

EnableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Ext Spk Switch' on"
cset "name='PortG Out En Switch' on"
]

DisableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Ext Spk Switch' off"
cset "name='PortG Out En Switch' off"
]
}

SectionDevice."Headphone".0 {
Comment "Headphones"

Value {
PlaybackChannels "2"
JackControl "Headphone Jack"
JackHWMute "Speaker"
}

ConflictingDevice [
"Speaker"
]

EnableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Headphone Switch' on"
cset "name='PortA Out En Switch' on"
]

DisableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Headphone Switch' off"
cset "name='PortA Out En Switch' off"
]
}

SectionDevice."Mic".0 {
Comment "Internal Microphone"

Value {
CaptureChannels "2"
CapturePriority "150"
}

EnableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Int Mic Switch' on"
cset "name='ADC1 Mux' 'PortC Switch'"
cset "name='PortC In En Switch' on"
]

DisableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Int Mic Switch' off"
cset "name='PortC In En Switch' off"
]
}

SectionDevice."HSMic".0 {
Comment "Headset Microphone"

Value {
CaptureChannels "2"
JackControl "Headset Mic Jack"
JackHWMute "Mic"
}

EnableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Headset Mic Switch' on"
cset "name='ADC1 Mux' 'PortD Switch'"
cset "name='PortD In En Switch' on"
]

DisableSequence [
cdev "hw:bytchtcx2072x"

cset "name='Headset Mic Switch' off"
cset "name='PortD In En Switch' off"
]
}
5 changes: 5 additions & 0 deletions cx2072x_fixes_and_manual/bytcht-cx2072x/bytcht-cx2072x.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Comment "Intel SoC Audio Device"
SectionUseCase."HiFi" {
File "HiFi.conf"
Comment "Default"
}

0 comments on commit 421d558

Please sign in to comment.