TAS2781 Audio Fix for Lenovo Slim Pro 9 16IRP8
Automatic audio fix for Lenovo laptops with TAS2781 amplifiers that lose bass and volume after the audio subsystem goes to sleep/idle.
Problem
On Lenovo Slim Pro 9 16IRP8 (and similar models), the TAS2781 audio amplifiers work correctly after boot, but when the audio subsystem enters power-saving mode (idle/suspended), only one speaker (0x38) properly resumes. The other speaker (0x3f) fails to wake up, resulting in:
- Loss of bass response
- Reduced overall volume
- Audio only from one speaker (right speaker works, left is quiet)
This is a kernel driver bug where the TAS2781 HDA codec driver doesn't properly reinitialize both amplifiers after resume.
Solution
This repository contains scripts that automatically detect when audio resumes from idle/suspended state and reconfigures both TAS2781 amplifiers via I2C.
System Requirements
- Laptop: Lenovo Slim Pro 9 16IRP8 (Product ID: 83C0) or similar models with TAS2781
- OS: Linux with PipeWire (tested on Fedora 43)
- Python: 3.8+ with
pulsectllibrary - Kernel: 6.x+ (must have i2c-dev support)
Installation
1. Install Dependencies
# Install required packages
sudo dnf install python3 python3-pip i2c-tools
# Install Python dependencies
pip install --user pulsectl
2. Clone Repository
git clone https://github.com/allankoechke/tas2781-audio-fix.git
cd tas2781-audio-fix
3. Install Scripts
# Make scripts executable
chmod +x tas2781-fix.sh tas2781-monitor.py
# Copy to system location
sudo cp tas2781-fix.sh /usr/local/bin/
sudo cp tas2781-monitor.py /usr/local/bin/
4. Configure Sudo Access
The monitor needs to run the fix script with sudo privileges without a password prompt:
sudo cp sudoers.d/tas2781-fix /etc/sudoers.d/
sudo chmod 0440 /etc/sudoers.d/tas2781-fix
⚠️ Important: Edit /etc/sudoers.d/tas2781-fix and replace ALL with your username:
sudo visudo /etc/sudoers.d/tas2781-fix
# Change: ALL ALL=(ALL) NOPASSWD: /usr/local/bin/tas2781-fix.sh
# To: yourusername ALL=(ALL) NOPASSWD: /usr/local/bin/tas2781-fix.sh
5. Install Systemd User Service
# Create user systemd directory
mkdir -p ~/.config/systemd/user
# Copy service file
cp systemd/tas2781-monitor.service ~/.config/systemd/user/
# Enable and start the service
systemctl --user daemon-reload
systemctl --user enable tas2781-monitor.service
systemctl --user start tas2781-monitor.service
# Enable user services to start at boot
sudo loginctl enable-linger $USER
6. Verify Installation
# Check service status
systemctl --user status tas2781-monitor.service
# View live logs
journalctl --user -u tas2781-monitor.service -f
Usage
Once installed, the monitor runs automatically in the background. It will:
- Monitor PipeWire audio node state changes
- Detect when audio transitions from idle/suspended to running
- Automatically run the fix script to reconfigure both amplifiers
You can also run the fix script manually:
# Test the fix immediately
sudo /usr/local/bin/tas2781-fix.sh
# Check the log
sudo cat /var/log/tas2781-fix.log
Monitoring
View real-time logs to see when the fix triggers:
# Follow monitor logs
journalctl --user -u tas2781-monitor.service -f
# View fix script logs
sudo tail -f /var/log/tas2781-fix.log
When audio resumes from idle, you should see output like:
[2024-12-09 00:45:23.456] SINK RESUMED TO RUNNING
Node ID: 58
Name: alsa_output.pci-0000_00_1f.3.analog-stereo
State: running
Description: Built-in Audio Analog Stereo
--------------------------------------------------------------------------------
================================================================================
[2024-12-09 00:45:23] Running TAS2781 fix script...
================================================================================
✓ TAS2781 fix completed successfully
Troubleshooting
Service Fails to Start
Check if PipeWire is running:
systemctl --user status pipewire.service
systemctl --user status pipewire-pulse.service
Fix Script Fails
Verify I2C bus access:
# Check if TIAS2781 device exists
ls -l /sys/bus/i2c/devices/i2c-TIAS2781:00
# Scan I2C bus (should show 0x38, might not show 0x3f until audio plays)
sudo i2cdetect -y 1
Speakers Still Quiet
-
Test the fix script manually while audio is playing:
# Start playing audio speaker-test -t sine -f 1000 -c 2 & # Run fix sudo /usr/local/bin/tas2781-fix.sh # Stop test killall speaker-test -
Check ALSA mixer settings:
alsamixer # Press F6, select your sound card # Ensure "Speaker" and "Bass Speaker" are unmuted and at max volume
View Detailed Logs
# Monitor service logs with timestamps
journalctl --user -u tas2781-monitor.service -f --output=short-precise
# Check for I2C errors in system log
sudo dmesg | grep -i "i2c\|tas\|audio"
# View fix script log
sudo cat /var/log/tas2781-fix.log
Uninstallation
# Stop and disable service
systemctl --user stop tas2781-monitor.service
systemctl --user disable tas2781-monitor.service
# Remove files
rm ~/.config/systemd/user/tas2781-monitor.service
sudo rm /usr/local/bin/tas2781-fix.sh
sudo rm /usr/local/bin/tas2781-monitor.py
sudo rm /etc/sudoers.d/tas2781-fix
sudo rm /var/log/tas2781-fix.log
# Reload systemd
systemctl --user daemon-reload
Technical Details
How It Works
- PipeWire Monitor: Python script monitors audio node state transitions using
pulsectl - State Detection: Detects when sinks transition from
idle/suspended→running - I2C Communication: Fix script directly configures TAS2781 amplifiers via I2C bus
- Register Configuration: Sets gain, volume, thermal protection, and power management registers
I2C Addresses
- 0x38: Right speaker amplifier (usually works)
- 0x3f: Left speaker amplifier (fails to resume without manual configuration)
Files
tas2781-audio-fix/
├── README.md # This file
├── LICENSE # MIT License
├── tas2781-fix.sh # I2C configuration script
├── tas2781-monitor.py # PipeWire state monitor
├── systemd/
│ └── tas2781-monitor.service # Systemd user service
└── sudoers.d/
└── tas2781-fix # Sudo configuration
Contributing
Issues and pull requests are welcome! If you have a different Lenovo model with TAS2781 amplifiers, please report whether this fix works for you.
License
MIT License - see LICENSE file for details
Credits
- Original I2C configuration script adapted from Linux audio mailing list
- TAS2781 datasheet: Texas Instruments TAS2781 Smart Amplifier
- Tested on Lenovo Slim Pro 9 16IRP8 (Product ID: 83C0, Subsystem ID: 0x17aa387e)