Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-17
12
Medium Priority
?
934 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
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

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 2000 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

972 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