loader image

Reply To: ASUS UX582L [Linux, No Audio, Fixed]

What makes us different from other similar websites? Forums Tech ASUS UX582L [Linux, No Audio, Fixed] Reply To: ASUS UX582L [Linux, No Audio, Fixed]

#8272
thumbtak
Moderator

[SOLUTION] Implementing the Dynamic hda-verb Fix for No/Low Sound

Following up on our previous discussions about the persistent low-volume or “no sound” issue on certain laptops: this guide details the definitive fix using a dynamic script and systemd. This fix addresses the root hardware bug where a critical internal component, like an amplifier, fails to turn on during the operating system’s startup.

This fix uses a dynamic script combined with a systemd service to ensure the speakers are always activated correctly upon boot, regardless of which card number your system assigns the sound chip.

Why The Script Works (The Simple Explanation)

This boot script’s purpose is to reliably fix the low-volume or mute issue on a specific, known type of audio chip by dynamically identifying and sending the required hda-verb commands. The script achieves this by first iterating through potential sound card slots (C0, C1, etc.) to see which ones are active, and then, crucially, it reads the name of the sound chip (the Codec) from the system files. Only when the script confirms the presence of the exact chip model that requires the fix (e.g., “ALC298”) does it execute the specific, hard-coded hda-verb sequence. This ensures the necessary commands—which directly flip the internal amplifier switch—are applied to the correct device, and only that device, guaranteeing the speakers turn on every time the system boots, regardless of how the operating system numbers the sound cards.

Step 1: Create the Fix Script

We’ll create a script named audio_fix.sh in the /usr/local/bin/ directory.

NOTE: If your codec is NOT ALC298, change the name in the line if [[ "$CODEC_NAME" == "ALC298" ]]; within the script below.

Use your favorite text editor (e.g., mousepad, nano, or vi) with sudo to create the file:

$ sudo mousepad /usr/local/bin/audio_fix.sh

Paste the following content exactly as shown:

#!/bin/bash

# --- 1. Define the specific fix with its required verbs ---
# These are the commands that fix YOUR specific audio chip model.
fix_my_specific_codec() {
local DEVICE=$1
echo "Applying fix for Known Codec on $DEVICE..."

# The essential hda-verb commands (replace with yours if needed)
hda-verb "$DEVICE" 0x20 0x500 0x1b
hda-verb "$DEVICE" 0x20 0x477 0x4a4b
hda-verb "$DEVICE" 0x20 0x500 0xf
hda-verb "$DEVICE" 0x20 0x477 0x74

# Optional: Log success
echo "hda-verb commands applied successfully."
}

# --- Main Logic: Find the Device Path and Identify the Chip ---
# We check through possible sound card slots (0, 1, 2)
for CARD_ID in 0 1 2; do
DEVICE="/dev/snd/hwC${CARD_ID}D0"

# Check if the hardware device path exists
if [ -e "$DEVICE" ]; then

# Read the name of the codec for this card from the kernel files
CODEC_NAME=$(cat "/proc/asound/card${CARD_ID}/codec#0" 2>/dev/null | grep -i 'Codec:' | awk '{print $NF}')

echo "Found Card $CARD_ID with Codec: $CODEC_NAME"

# --- Send the Direct Commands ---
# **ACTION:** If the codec name matches the one we need to fix, run the function.
if [[ "$CODEC_NAME" == "ALC298" ]]; then
# IMPORTANT: Change "ALC298" to the actual name of your chip if it is different!
fix_my_specific_codec "$DEVICE"

# Success! Exit the script immediately so we don't check other cards.
exit 0
fi

fi
done

echo "Script finished. No matching known codec found or patched."
exit 0

Step 2: Make the Script Executable

We need to set the executable permission so the system can run the script.

$ sudo chmod +x /usr/local/bin/audio_fix.sh

Step 3: Create the Systemd Service File

Next, we create a service file that tells systemd when and how to run our script during startup.

Use your text editor with sudo to create the file:

$ sudo mousepad /etc/systemd/system/audio_fix.service

[Unit]

Description=Audio Fix at Startup for Specific Codec

After=sound.target

[Service]

Type=oneshot

ExecStart=/usr/local/bin/audio_fix.sh

RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

Step 4: Activate and Start the Service

These three commands are essential. They tell systemd to load the new service, set it to run automatically on every boot, and run it immediately for testing.

1. Reload the systemd manager configuration

$ sudo systemctl daemon-reload

2. Enable the service to run automatically on boot

$ sudo systemctl enable audio_fix.service

3. Start the service immediately (to test it now without rebooting)

$ sudo systemctl start audio_fix.service

Step 5: Test the sound

$ speaker-test -t wav -c 2

Stop with ctrl + c.

TAKs Shack