Tuesday, August 23, 2011

ASUS Laptop Audio Jack Fix for Linux - ALSA Configuration

Update: This fix is not required with a current Linux kernel: use GUI instead; e.g - Sound Preferences - Output - Connector - Analog Headphones/Speakers.

I have created a program to automatically apply a correction to the ASUS A42J (or equivalent) Audio Jack detection for Linux Systems (EL5/EL6) - ASUS-A42J_soundfix.zip. It is designed to be manually executed on start-up (root privileges required), and instructions are provided in Install.txt. Alternatively the ASUS-A42J_soundfix.bat script can be made to execute upon system boot (where the exact configuration is distribution dependent).

Some additional information is provided here;

1. to manually configure ALSA hda_analyzer:
(based on https://bugs.launchpad.net/ubuntu/+source/linux/+bug/604771)

http://www.alsa-project.org/main/index.php/HDA_Analyzer
wget -O run.py http://www.alsa-project.org/hda-analyzer.py
su root
python run.py OR python hda_analzser.py
Node[0x14] PIN -> Val[0] + Val[1] -> mute
Node[0x1a] PIN -> Connection List -> Audio Mixer [0x0c]

2. to modify ALSA hda_analyzer code for arbitrary problem:
(based on http://ubuntu42.blogspot.com/2010/05/easiest-fix-for-sound-sony-vaio.html)

Note if you are interested in creating a replicant of this software program for an entirely different problem (say ALSA configuration fix on another brand of laptop), you might be interested to know exactly what is the difference between the python code here and that of the original hda_analyzer source. The best way to achieve this is to perform a diff of the modified source code here and the version of hda_analyzer used to create this mod (2010).

diff hda_analyzer-orig.py hda_analyzer.py
352c352
< --- >
357c357,360
< --- > kaartteller=0 #Modification made here
> codecteller=0 #Modification made here
> nodeteller=0 #Modification made here
>
358a362
> kaartteller=kaartteller+1 #Modification made here
366a371
> codecteller=codecteller+1 #Modification made here
375a381
> nodeteller=nodeteller+1 #Modification made here
384a391,401
>
> #Modification made here;
> if kaartteller == 1 and codecteller == 1 and nodeteller == 19: #Node[0x14] PIN
> node.amp_vals_out.set_mute(0, True) #Val[0] set to Mute
> node.amp_vals_out.set_mute(1, True) #Val[1] set to Mute
> if kaartteller == 1 and codecteller == 1 and nodeteller == 25: #Node[0x1a] PIN
> node.set_active_connection(int(0)) #Audio Mixer [0x0c]

---

diff hda_analyzer.py ASUS-A42J_soundfix.py
496c496
< gtk.main() --- > #gtk.main()