Solved

Cannot get jack sensing to work in Linux (Meego) with Realtek 272X codec

Posted on 2010-11-17
12
921 Views
Last Modified: 2013-12-15
Hi,

First of all please forgive me, if I am doing something wrong. This is my first post here.

I have an Acer Aspire One DMA250 PC running Meego 1.0. In an application i am making
i need to check if headphones are connected to the soundcard minijack output or playback is
over the builtin loudspeakers. To do that i do something like shown in the attached jacksensetest.c
example. It works on another Dell PC running Ubuntu I have. On the Acer Aspire One PC there was
no /dev/input/eventX present which held information about the sound card but everything was
working fine beside that.

The Acer Aspire one PC has an Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller
(rev 02) and Realtek ALC272X codec.

My Meego kernel version is 2.6.35.3-6-netbook. It is the Linux kernel from kernel.org with a few
patches applied.In order to get jack sensing working i tried to apply the following patch:
http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=commitdiff;h=bf1b022588eba78c990fd58fd2471cd92c2c5683;hp=1cc9e8f4c45999e6069f41521d9d391eeeccc3b3
and defined CONFIG_SND_HDA_INPUT_JACK

Now I have
/dev/input/event6: "HDA Intel Mic"
/dev/input/event7: "HDA Intel Headphone"
but I am still not able to do jack sensing. If I use ioctl to query /dev/input/event7
(like in jacksensetest.c) it always returns 0 (not connected).

Now I have started to dig deeper into the kernel/driver code and have inserted a lot of printk()'s
in the patch_realtek.c file. It shows me that the jack sensing events are not generated when
plugging/unplugging headphones.
If I run HDAAnalyzer it does not list "Input Sense" in the PIN Caps list for the Jack HP out PIN (0x21).
That makes me think that it is either not supported or somehow I have to activate this functionality.
Jack sensing should be supported and it also works in Windows 7.

Does anyone know how to enable this jack sensing feature?
Or maybe I am doing things wrong or overlooking something?

/Kim
jacksensetest.c
alsa-info.txt
codec.txt
0
Comment
Question by:DevSW
  • 8
  • 4
12 Comments
 
LVL 18

Expert Comment

by:TobiasHolm
Comment Utility
Hi!

You could try booting an Ubuntu CD (or some other distro) and test your code. This way you can figure out if the problem is in your current Linux installation or in the HW/BIOS/Linux OS.

I'll try your code on my machine to see if I can get it to work! (later though because I'm not at a computer right now)

Regards, Tobias
0
 

Author Comment

by:DevSW
Comment Utility
Hi Tobias!

I have tried Ubuntu netbook 10.10 with uses kernel 2.6.35-22-generic and also Meego 1.1. The same thing happens. No audio devices under /dev/input and no jack detection.

My understanding is that it is a driver issue (and kernel issue as the realtec 272X codec is built into the kernel) and not related to which Linux distribution I am running.

I will try to install the latest kernel from git (if possible without making things crash).

Regards, Kim
0
 
LVL 18

Expert Comment

by:TobiasHolm
Comment Utility
>It works on another Dell PC running Ubuntu I have.

What kernal are you using on the Dell?
0
 

Author Comment

by:DevSW
Comment Utility
Actually it works on two other Dell PC's. The first Dell PC I mentioned uses kernel version 2.6.32-25-generic. The reason jack sensing works on these PC's is that they have other sound card hardware/codec.
As I mentioned one thing that could be useful would be to test if the newest kernel from git would support jack sensing on the Acer Aspire One PC. Unfortunately it might not be that easy to perform that test. I do not want to crash the meego installation and if i boot from an Ubuntu memory stick or CD i cannot install another kernel as it requires me to reboot (i think).
If i performed that test it would tell me if the realtek driver has a bug (because jack sensing is still nok working with the newest kernel/drivers) or if I have a bug in my custom patch_realtek.c file.
0
 

Author Comment

by:DevSW
Comment Utility
More information on the problem:

There is a function in hda_codec.c that examines if "presence detection" is possible:
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)

From patch_realtek.c the call is done like this: alc_report_jack->snd_hda_jack_detect->snd_hda_pin_sense

It always returns 0 (meaning nothing is inserted in the jack connector).

I have noticed that when playing back audio on the meego PC and plugging in the headphones, audio is only being played back through the headphones as it should. So i think in that way jack sensing is working fine (assuming that this functionality is not implemented in hardware - it does not look that way in the driver).

More information about a similar problem can be found here:
https://patchwork.kernel.org/patch/21713/

I have downloaded the High Definition Audio Specification but I have not understood the codec architecture good enough to pin point my problem. I am trying to read out the pinse sense capability of the device by calling snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0, AC_VERB_GET_PIN_SENSE, 0) from inside the alc_report_jack function but it seems I have parsed a wrong NID (hp_pins[0]) because the returned int value is -2147483648.

/Kim
0
 

Author Comment

by:DevSW
Comment Utility
More information:

As I mentioned the loudspeaker output is muted when the headphones are plugged in. By logging in the driver (printk()'s) I found out that when headphones are connected, the following functions in patch_realtek.c are called:
alc_sku_unsol_event
alc_automute_pin
alc_automute_speaker
When the headphones are unplugged:
alc_sku_unsol_event
alc_automute_pin
alc_automute_speaker
alc_report_jack (which correctly reports jack status 0)

So maybe some of the problem is that alc_report_jack is not called when the headphones are plugged in.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 18

Assisted Solution

by:TobiasHolm
TobiasHolm earned 500 total points
Comment Utility
>So maybe some of the problem is that alc_report_jack is not called when the headphones are plugged in.

Sound's like you're on to something there!

To be able to test different Linux cores in your Acer you could switch hard drive in the laptop or install Linux to a USB stick and use this stick as a hard drive.
0
 

Author Comment

by:DevSW
Comment Utility
Hi again,

It sounds like a good idea to install Linux to an USB stick for future reference.

I found the problem. It was a bug in alc_automute_speaker(struct hda_codec *codec, int pinctl) where alc_report_jack(codec, spec->autocfg.hp_pins[i ]); was not called in the case headphones was plugged in. It works now. I will report the bug to the Realtek Linux driver development team. I will leave this question open until I have talked to them.

Regards, Kim
0
 
LVL 18

Accepted Solution

by:
TobiasHolm earned 500 total points
Comment Utility
That's good news! I'm glad you found the bug!
0
 

Author Comment

by:DevSW
Comment Utility
Hi,

I have not heard much from the Linux driver development team but I think I will close this questions anyway as I have made a fix myself and have gained the necessary insight to investigate this kind of problems.
Thank you for your help Tobias.

/Kim
0
 

Author Comment

by:DevSW
Comment Utility
Should have given Tobias a few points.
0
 

Author Closing Comment

by:DevSW
Comment Utility
The reason for accepting my own comment as part of the solution:
My own comment was the only solution given.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now