Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 936
  • Last Modified:

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

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
DevSW
Asked:
DevSW
  • 8
  • 4
2 Solutions
 
TobiasHolmCommented:
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
 
DevSWAuthor Commented:
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
 
TobiasHolmCommented:
>It works on another Dell PC running Ubuntu I have.

What kernal are you using on the Dell?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
DevSWAuthor Commented:
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
 
DevSWAuthor Commented:
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
 
DevSWAuthor Commented:
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
 
TobiasHolmCommented:
>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
 
DevSWAuthor Commented:
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
 
TobiasHolmCommented:
That's good news! I'm glad you found the bug!
0
 
DevSWAuthor Commented:
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
 
DevSWAuthor Commented:
Should have given Tobias a few points.
0
 
DevSWAuthor Commented:
The reason for accepting my own comment as part of the solution:
My own comment was the only solution given.
0

Featured Post

Technology Partners: 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!

  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now