Solved

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

Posted on 2010-11-17
12
932 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
12 Comments
 
LVL 18

Expert Comment

by:TobiasHolm
ID: 34162074
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
ID: 34162199
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
ID: 34162914
>It works on another Dell PC running Ubuntu I have.

What kernal are you using on the Dell?
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

Author Comment

by:DevSW
ID: 34163058
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
ID: 34163167
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
ID: 34163629
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
 
LVL 18

Assisted Solution

by:TobiasHolm
TobiasHolm earned 500 total points
ID: 34164277
>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
ID: 34170914
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
ID: 34172103
That's good news! I'm glad you found the bug!
0
 

Author Comment

by:DevSW
ID: 34215885
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
ID: 34215921
Should have given Tobias a few points.
0
 

Author Closing Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

617 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