Turn Your Mic Jack Into a Headphone Jack

25
12/10/2013 David Henningsson « A better sounding world http://voices.canonical.com/david.henningsson/author/diwic/ 1/25 Canonical About Canonical About Ubuntu Enterprise services Engineering services Consumer services Type to search go A better sounding world Author Archive « Older Entries David Henningsson Ubuntu Touch audio stack for 13.10 release August 27th, 2013 by David Henningsson Categories: PulseAudio No Comments Up until now, we’ve been using Android’s AudioFlinger for playing back and recording audio. Starting with tomorrow’s image, that is no longer true. Instead we’re talking directly from PulseAudio to ALSA, or the Android audio HAL when necessary. In short, here’s how PulseAudio now works: For normal playback and recording, PulseAudio talks directly to alsalib, just as on the desktop. For detecting whether a headphone/headset is plugged in or not, PulseAudio now has code for reading that from the Android kernel, through the “switch” interface . For normal mixer setup, we use ALSA UCM mixer files. For setting up voice calls, we talk to the Android Audio HAL through a PulseAudio module. This provides somewhat of a compromise between features and porting effort: By using the ALSA library whenever we can, we can access PulseAudio’s timer scheduling and dynamic latency features. Having the straightest path possible for playing back music should help efficiency (and in extension, battery life). At least in theory – we haven’t actually done measurements. Using the Audio HAL for everything mixer related would have been optimal, but it turns out that the audio HAL is too smart: it refuses to set up the mixer, unless PCM data is also sent to it, which is what we wanted to avoid. So then we had to set up the mixer manually too. However, we still could not avoid using the Audio HAL altogether: when starting and stopping voice calls, the Audio HAL talks to the modem and other components in the kernel to route the voice call between the modem and the sound card. Hence we ended up with this compromise approach. Current status At the time of this writing, this is working best on Nexus 4. The Galaxy Nexus works for the most part, except for bug 1217072 . I intend to add Nexus 7 support shortly. If anyone wants to help testing Nexus 10, let me know. For porters: if you need to do the same

description

Worked perfectly for me.Re-cofigure your Mike / Speaker or Headphones jack.

Transcript of Turn Your Mic Jack Into a Headphone Jack

Page 1: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 1/25

CanonicalAbout CanonicalAbout UbuntuEnterprise servicesEngineering servicesConsumer services

Type to search go

A better sounding world

Author Archive

« Older EntriesDavid Henningsson

Ubuntu Touch audio stack for 13.10 release

August 27th, 2013 by David HenningssonCategories: PulseAudioNo Comments

Up until now, we’ve been using Android’s AudioFlinger for playing back and recording audio.Starting with tomorrow’s image, that is no longer true. Instead we’re talking directly from PulseAudioto ALSA, or the Android audio HAL when necessary.

In short, here’s how PulseAudio now works:

For normal playback and recording, PulseAudio talks directly to alsa­lib, just as on the desktop.For detecting whether a headphone/headset is plugged in or not, PulseAudio now has code forreading that from the Android kernel, through the “switch” interface.For normal mixer setup, we use ALSA UCM mixer files.For setting up voice calls, we talk to the Android Audio HAL through a PulseAudio module.

This provides somewhat of a compromise between features and porting effort: By using the ALSAlibrary whenever we can, we can access PulseAudio’s timer scheduling and dynamic latency features.Having the straightest path possible for playing back music should help efficiency (and in extension,battery life). At least in theory – we haven’t actually done measurements.

Using the Audio HAL for everything mixer related would have been optimal, but it turns out that theaudio HAL is too smart: it refuses to set up the mixer, unless PCM data is also sent to it, which iswhat we wanted to avoid. So then we had to set up the mixer manually too. However, we still couldnot avoid using the Audio HAL altogether: when starting and stopping voice calls, the Audio HAL

talks to the modem and other components in the kernel to route the voice call between the modem andthe sound card. Hence we ended up with this compromise approach.

Current statusAt the time of this writing, this is working best on Nexus 4. The Galaxy Nexus works for the mostpart, except for bug 1217072. I intend to add Nexus 7 support shortly. If anyone wants to help testingNexus 10, let me know.

For porters: if you need to do the same

Page 2: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 2/25

Unfortunately, this means some additional work for porters, because you need to write UCM mixerfiles. What’s worse, UCM is lacking good documentation. For that reason, I hesitated somewhatbefore deciding to actually use UCM at all, but it’s the closest we have to a standard for setting upmixers on embedded devices right now.

But to give you a two­minute crash course in UCM and how it’s used in Ubuntu Touch – start byhaving a look in /usr/share/alsa/ucm/apq8064­tabla­snd­card/ directory. You’ll need to create a similardirectory for your device. You’ll find the right directory name if you look in /proc/asound/cards.

Second, look at apq8064­tabla­snd­card.conf. Rename and copy into your own UCM directory. Ifyou’re making a tablet image (that can’t make voice calls), you can remove the VoiceCall part (andthe corresponding file).

Third, look at the HiFi file. This is where all fun happens. Notice the device names, which arehardcoded into telepathy­ofono and need to match: “Speaker”, “Earpiece” and “Headphone” forplayback, plus “Handset” and “Headset” for recording.

Fourth, if you need voice calls, also look at the VoiceCall file. Btw, the verb names “HiFi” and“VoiceCall” also need to match.) This is largely empty, because the mixer setup is handled by theAudio HAL, but there is a twist here that took a while to get right: For PulseAudio’s UCM to work, itneeds to open a PCM device. However, at the time where UCM tests this, the voice call is not yet setup. So, you might need to set up the mixer just a little, so that the PCM can open. (On desktops, PCMcan always open, regardless of mixer state. This is not always true on embedded devices, that areusing ASoC.) It’s a bonus if you can find a PCM that actually plays back audio, because then you canget notification sounds while on the phone.

And this concludes the two minute crash course – happy porting!

(Side note: Sorry if the permalink – or comment pages etc – to this blog leads you to a blank page.I’ve reported the bug to the relevant team in Canonical, but at the time of this posting, they arelooking into it but have not yet fixed it.)

David Henningsson

I ported my game to Ubuntu

April 14th, 2013 by David HenningssonCategories: Uncategorized8 Comments

If you just want to play the game, here’s where you find it. Or, in a terminal window write:

sudo add-apt-repository ppa:diwic/theblobgamesudo apt-get updatesudo apt-get install theblobgame

Then just search for “blob” in the Dash.

The rest of this blog post is mostly directed towards game developers.

Page 3: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 3/25

Background and motivation

Ten years ago I finished a game called “The Blob Game”. It was a 2D platform style game, more cutethan violent. My cousin had made the graphics, a level editor, and part of the game engine. I madeseven levels, music, and completed the code. Back then, I was still working for a company doingclosed source software for Windows, so naturally this game was a Windows game.

A while ago I decided to try to port this game to Ubuntu. My main motivations were:

To see how easy (or hard) it was, given my current level of experience. Also because wecurrently have some undergoing efforts to make Ubuntu a better gaming platform, and whatbetter way to do that, than to become a game developer yourself?People complain that there are not enough games available in Ubuntu – I wanted to make mysmall contribution to help even that out.Nostalgia purposes – after all, most of the work with the game was to make the levels and theartwork, rather than actual code. All of this can be reused, and it would be nice if this gamecould entertain a new audience.

Overall, the experience has been good. Sure, there has been some work to do and new things to learn

and conquer, but there has been very little of frustration. A fun side project!

One of the strength and weaknesses of the Linux ecosystem is all the choices you can, and have to,make. What components do you choose to build your software on? That can be bewildering,especially if you’re new to Linux and unfamiliar what components are suboptimal for one reason oranother. I would therefore like to talk you through the choices I made and why I made them. Asusual, these are my own opinions, not my employer’s.

Language: C

To give some background, my cousin and I started programming twenty years ago. Back then, myfather introduced me to Turbo Pascal, which was more powerful than the QBasic that came withDOS 5.0. Ten years later, I was using Delphi (the Windows continuation of Pascal) at my work. Sothe game was written in Delphi, mixed with some hand written assembly code (!).

Was it possible to reuse the code written? I looked at the available compilers:

GNU Pascal. This project seems mostly abandoned, so not a stable choice for the future.FreePascal. This was the main alternative, but it has its own code generator (not integrated withGCC or LLVM), so chances are it won’t keep up in the future. Also, if you need to link to alibrary, chances are you have to translate headers yourself.

So; rewrite the code. In what language? My choice fell on C, for the following reasons:

It is a very popular language, maybe even the most popular one. It is likely to be around for along time, and have support for new processors and architectures as they come to market.It is compatible with everything. In fact, it’s what every other language tries to be compatiblewith (Java has JNI, Python has C extensions, etc).

Page 4: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 4/25

with (Java has JNI, Python has C extensions, etc).It is what I use at work, so I know the language very well. (Both Linux and PulseAudio arewritten in C.)I like the low memory footprint and predictability of C – you want a game to run fluently, theaudio to run at a reasonably low latency, and so on. With the exception of calling functions youdon’t know about, you can almost see how quick your code executes. I’m not sure how wellJava, Python, and the other garbage collecting languages do in this area; so my fear might beunfounded, but at least I know C does well.

Gaming library: libSDL

Fortunately, the cross­platform toolkit libSDL is very well supported under Linux. I have almost onlypositive experiences of this library: it seems very stable. It handles graphics (window setup, fullscreenetc), input events (keyboard, mouse, gamepads just work), audio, and more. The documentation isextensive and there are plenty of examples out there. And because libSDL is already used by so manygames already, most distributions make sure libSDL works on their software and hardware.

What about OpenGL? Well, this is a 2D game, so I don’t need 3D. It is possible I could use somehardware acceleration for the scaling (the frame is rendered in 320×200, then upscaled to the screen’sresolution), but my very simple scaler seems to perform well enough. As such, there was no real needto bring in a dependency on OpenGL.

Music library: FluidSynth

First I’m a more than a bit biased on this dependency, as I’m one of the FluidSynth developers.However, the reason I first got involved with FluidSynth was that I wanted to use it in a game, andneeded to fix something in the library…

FluidSynth is a softsynth – it takes MIDI data and a soundfont, and gives you rendered audio as aresult. This has the drawback that you need to download a soundfont too, and the only one availablein the Ubuntu archive is > 100 MB. The good thing is that FluidSynth is very embeddable into manydifferent kinds of applications, so taking the audio output, mixing it with sound effects, and then sendit to the sound card (with libSDL) was easy. It is also easy to manipulate the MIDI in real­time – inthis game I’ve used it to pitch down the audio when you die.

GUI toolkit library: glib and GTK3

Let’s first admit it; in the Linux world we don’t have anything as stable as the Win32 API for creatingwindows. The two main contesters, GTK and QT, are both rewritten every five years or so. So if I,ten years from now, need to run this game again, chances are that I have to rewrite this part. The GUIis just used in the beginning though (to setup the game), so it shouldn’t be too much work.

I chose GTK over QT here because

I had previous experience with GTKQT adds complexities to your build system, as you need not only a C++ compiler, but also aspecial preprocessor to turn some special QT constructs into valid C++ code.

Build system: simple Makefile

In my case, my application takes a few seconds to compile. For really simple applications like thisone, I find build systems such as autotools or CMake to be more trouble than what they solve. In bothcases, you’ll have to learn an additional language just to specify your build dependencies. (Autotoolsalso has a few nuisances, such as requiring some extra files to be present, and in all upper­case, suchas AUTHORS or NEWS.)

For larger projects, they make more sense though as they might help you create libraries for differentplatforms, give nice error messages when build dependencies can not be found, etc.

Licensing: LGPL­2 + CC­BY­SA

Page 5: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 5/25

This is always a tricky and controversial subject, and I’d like to reiterate that this a layman’s thoughtson the topic and nothing else.

GPL is the strongest license when it comes to free software. But that also makes it a veryincompatible license, it is essentially impossible to link GPL code with everything that’s notextremely weak (e g BSD) or explicitly made to fit with GPL (e g LGPL). One example of anincompatible license is MPL 1.1 – this was a quite popular license in the Delphi community,and the incompatibility with GPL was a real pain.It is not obvious where the boundaries between GPL and non­GPL code can be, causingconfusion in court from time to time. FSF might offer some advice on how to interpret thelicense; but they’re not a neutral party. In this case, I find the LGPL, the second strongestlicense, more clear.So LGPL­2, LGPL­3 or LGPL2+? Well, to me, any “at your option, any later version” clauseis out of the question; for me, that’s essentially the same as giving your code away to the FSFas they can relicense your code any way they wish. And LGPL­2 is shorter than LGPL­3because LGPL­3 includes the full GPL­3 license code, too.LGPL­2 is suitable for code, but not for data. So music, graphics and levels are licensed underCC­BY­SA. I was considering adding “non­commercial”; but the border between commercialand non­commercial can be fluid, and might also be a problem with the DFSG, so I skippedthat part.

Update: Seems I didn’t read closely enough – LGPL­2 has a GPL­2+ clause, now making it possiblefor the FSF to relicense my code by making a new GPL version.

I also downloaded new sound effects (which is the only part not completely made by myself or mycousin), to make sure there was no licensing problems with those.

Getting it into the Ubuntu Software Center

Unfortunately, this does not currently work for free applications. While adapting my packaging to fitthe requirements was relatively straight­forward, and also walking through the dialogs for appsubmission, when all this work was done, I was met by the following message:Thank you for submitting a gratis Free Software application through MyApps. Atthis time we are unable to process this request, as we are working on theimplementation of a new app upload process.

Bummer.

A packaging tip

While we’re on the topic of packaging, let me just share a quick tip. If you’re new to Debianpackaging (the system used in Ubuntu), and just want to package your own app, one thing to thinkabout is that the packaging system was designed for having coders and packagers belong to separateorganisations. So that means, that if you during packaging find a bug in your code, you’re meant tomake a temporary patch, send that the coder, who will then make another release of the non­packagedsoftware, which you will then package. In practice, this is a bit heavy­weight if you’re just one personand don’t keep packaging and code apart, so I used the following shortcut:tar -cjf theblobgame_0.20130202.orig.tar.bz2 --exclude=debian theblobgame-

Page 6: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 6/25

tar -cjf theblobgame_0.20130202.orig.tar.bz2 --exclude=debian theblobgame-0.20130202If you fixed something in the code and want to work on the packaging, the command above willcreate a new “code release” from the packaging system’s point of view.

…and finally, it’s free software!

This means you’re allowed not only download and run this game, but also look at the code, copy­paste parts into your own game (under the terms of the LGPL­2!) or just use for inspiration. You canfix a bug or a feature and send me patches (or publish the modified code yourself), etc. Enjoy!

Update: Someone asked me how to get the source, so here’s a quick howto:If you have executed the lines in the top of this blog post, just change into a suitable directory andexecute “apt­get source theblobgame”. Before you build, you can use “sudo apt­get build­deptheblobgame” to automatically install all build dependencies. Building can be done with “dpkg­buildpackage ­b” (from the source code directory). Then install the resulting .deb package (“sudodpkg ­i theblobgame_version.deb”) to test.

If you’re not running Ubuntu/Debian, you can get the source from going to the PPA page, click“View package details”, click one of the arrows on the left side in the table, and download the fileending with “orig.tar.bz2″.

Disclaimer: This does not mean that the source is written by the book, with lots of helpful comments,etc. The game engine is mostly a quick translation of the code as it looked like ten years ago, withnew glue code added for interfacing with the libraries I now depend on.

David Henningsson

Upcoming changes to the Intel HDA drivers

January 18th, 2013 by David HenningssonCategories: Uncategorized25 Comments

Takashi Iwai, the Linux sound maintainer, is about to merge a patch set of about 150 patches intolinux­next. These changes, in short, unify the different HDA codec drivers.

Introduction and background

First, the basics: HDA Intel is the current standard protocol for accessing your built­in soundcard, aswell as HDMI/DisplayPort audio, and is used in almost all desktop and laptop computers since about2005. In the HDA Intel world, there are controllers and codecs. The codecs also have a configuration,which tells which pins of the codecs that are connected to what input or output (this is set byBIOS/UEFI).

Hardware is very diverse: The HDA Intel driver supports at least 50 different controllers, and about300 different codecs. On top of that, every codec usually support many different configurations.The codecs come from 10­12 different vendors, and within the same vendor, it is more likely that thecodec layout is somewhat like other codecs from the same vendor. As a result, the HDA codec driveris split up in 10­12 codec driver files, one per vendor. These files are to some degree copies of eachother, but also contains every vendor’s specials.

What changes?

Takashi’s patches are solving a long term maintenance problem: as we want to add new features tothe kernel drivers, we would previously have to do this once per codec – whereas with the unificationof codec drivers, we would just have to add this code once. Or possibly twice, as the HDMI codecswill still have its own codec driver. In addition, new codec hardware is more likely to “just work”, orat least partially work, without explicit support in the kernel. The potential downside, of course, is thatas you improve the driver to solve some edge case, you’re more likely to screw some other edge case

Page 7: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 7/25

as you improve the driver to solve some edge case, you’re more likely to screw some other edge caseup.

There’s not much of new features added in this new, generic driver at this point. However, if youhave an “unusual” codec chip vendor, you might see minor improvements as these are brought up tofeature parity with the more common codecs.

When does it change?

As usual, you can’t know until it’s in there. Takashi’s latest plan is to make the move for 3.9 for atleast some of the codecs, and 3.10 for the rest of them.

Update: Some blog, referencing this one, said this feature would come to Ubuntu 13.04. Ubuntu13.04 uses kernel 3.8, so this feature won’t be in Ubuntu until 13.10.

Update 2: As of 2013­01­23, the new code has been merged, for all codecs, for linux­next (kernel3.9)!

Regressions and testing

Judging from the database you might have contributed to by yourself by submitting your alsa­info,there are about 6000 different machines out there, and there is not enough manpower to test them all.So we need a different approach. Conveniently, Takashi has written an emulator called hda­emu totest the codec driver code, and I’ve improved that emulator with some scripting, so that hda­emueffectively becomes an automated test suite. The test suite is still very incomplete, but it at least runs afew different tests such as faked playback, S3, and manipulating of volume controls, and checks ifhda­emu crashes or reports an error. And sure enough, when running this test suite over all the alsa­infos in the database, a few regressions were discovered that I was able to fix.

So far, so good. If it weren’t for the fact that hardware often does not work exactly as advertised. Theparser algorithm for reading the codec layout and creating a working kernel driver out of it, must nowtake all codecs from all vendors into account. The old vendor­specific parser might have done thingsin one way and the new parser might do things a different way, causing the audio to be routeddifferently.

As an example, assume the codec is broken in such a way that it advertises two audio paths, but inpractice only one of the paths actually works. The new parser might then route the audio differentlyfrom the old one – and as a result it will look like audio should really work, in theory. In practice,there is nothing but silence. Another example could be that maybe the new driver will power downdifferent parts of the codec in different order than the old driver did, causing your speakers to click.

How can I help?

Right now, what’s needed is more testing on real hardware. Takashi has called for testing of his hda­migrate branch of the sound­unstable tree.

If you’re running Ubuntu, I have made packages for 12.04, 12.10 and 13.04 – just download, install it(you might need to install dkms and kernel headers too). Then reboot and test. Simply uninstall thepackage and reboot when you’ve finished testing.

Update: I will probably close the comments soon due to the amount of spam coming in that way.Please report back – especially if you did see a regression – to the alsa­devel mailing list. Thanks!

Update 2: As the code is now merged into linux­next, please use these instructions to try it out onUbuntu. Thanks!

David Henningsson

UCADay: Appreciation for Ubuntu Women!

November 20th, 2012 by David HenningssonCategories: Uncategorized

Page 8: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 8/25

Categories: Uncategorized1 Comment

As part of the Ubuntu Community Appreciation Day initiative, I’d like to write an appreciation forfemales – of all ages – that we have within Ubuntu and upstream communities, and why I’d like tosee more of the same. To do this, I’ve taken the liberty of generalising a bit based on my ownpersonal experiences.

First off, many women have excellent communication and conflict resolution skills. I envision thiscould come to very good use, including upstream. You see, we software developers can be reallypicky – which is a good thing, as long as this helps us prevent bugs. But we also tend to set up rulesfor ourselves and our processes, and we need a counterweight to that in order not to become rule­following robots, which is no fun. A controversial patch can easily lead to heated, discouragingdebates and somebody running off, making a fork of the project, together with half of the squad. Seenfrom an Ubuntu perspective, better communication and conflict resolution skills might help us tomaintain fewer remixes and derivatives – but the remaining ones would be more polished and workbetter.

Second, a mixed company working place is good for everyone. Before working at Canonical, I hadbeen working at both offices with only men, and with both men and women. My experience was thatat the male­only office, discussions tended to be more matcho – coffee break chats were often aboutsports or women, if I remember correctly. And even if background images of women in bikini andjokes towards the vulgar didn’t offend me, I didn’t particularly enjoy it either.At the mixed company working place, discussions in general had a friendlier tone, and included awider area of topics. It was just…better.(Side note: while discussing this with a female colleague a long time ago, she told me she had beenworking at a women­only place, which was plagued by gossiping to the extent that she was afraid tobecome ill – because on the day she would not be at work, they would gossip about her. Judgingfrom that, mixed company is likely good for everyone, not just men.)

Third, women know what women want. Or, at least, are slightly more likely to know. Software ismore likely to get new features, bug fixes, packaging, support, advertising blog posts and so on, ifthere are people with sufficient skill and interest in that particular software. When more women getinvolved in software development, the end result will be more useful for women. If Ubuntu’s evergoing to reach 200 million users: if it works great for twice as many people, that would certainly help!

So, I would like to say thank you to all women involved in open source communities, both Ubuntuand upstream. That includes a thank you for not quitting when times get rough.

And finally, if I may extend my appreciation to an invitation: you don’t have to be as fantastic as theopen source women I’ve met, to be contributing to Ubuntu, Debian, or upstream. If you already haveskills, that helps, but for the most part, you’ll learn as you go. Commit to respecting each other first,and then you can start helping out with everything from writing code to organizing events. Welcome!

Disclaimer: As usual, these are my own views rather than those of my employer, my family, oranyone else. Also, just to make the point clear, this is not scientific research and does not claim thatwomen are in general different from men – we all are so much different from, and so much morethan, what an average person of the same gender would be. It is just my “thank you” post, based onmy own personal experiences.

[Thanks to Leann Ogasawara for providing some useful feedback when writing this blog post.]

David Henningsson

Pulseaudio conference – less than a month away!

October 4th, 2012 by David HenningssonCategories: PulseAudio2 Comments

Page 9: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 9/25

2 Comments

The first PulseAudio conference is approaching quickly. This is a shoutout for people who might beinterested, but missed the mailinglist announcement.

The conference will be Friday 2nd November 2012, and colocated with Ubuntu Developer Summitand Linaro Connect, in Bella Center, Copenhagen.

There is no attendance fee, but you’ll need a UDS or LC registration (which are also free) to be ableto get into the conference area. (Note: LC might be the safer bet here as UDS ends on Thursday)

There had been a few topics brought up on the mailinglist, but we welcome anyone who would liketo contribute to constructive discussions and help to shape the future of PulseAudio!

If you would like to attend, how about you write an email to the pulseaudio­discuss mailinglist withthe topic(s) you want to bring up, and maybe a small presentation with your background andinterests? Of course, if you mostly want to listen in rather than bring your own topics, that’s okay too!

David Henningsson

Top five wrong ways to fix your audio

July 13th, 2012 by David HenningssonCategories: PulseAudio, Uncategorized17 Comments

The audio stack in Linux/Ubuntu evolves over time. What used to be good advice is not necessarilygood advice anymore. (That also means, that if you happen to read this blog post in 2019 orsomething, don’t trust it!)

Here are some things that people try, and sometimes they even fix the problem, but are often bad inone way or the other. Or at least, they have side effects one needs to be aware of. So – while there arevalid exceptions, as a rule of thumb, don’t do the following:

5. Don’t add your user to the “audio” group

A user has access to the audio card if that person is either logged in – both VT and GUI login counts,but not SSH logins, or if that user is in the “audio” group. However, on the level of access we’retalking about here, only one user has access at a time. So the typical problem scenario goes like:

User Homer has an audio issue, and tries to fix it by adding himself to the audio group. Thisdoesn’t help to resolve the problem.Homer discovers his audio is muted, and unmutes it. Happy to have his audio issue resolved, heforgets he’s still in the audio group, or doesn’t realise it leads to problems.User Marge comes and wants to borrow the computer. Homer does a fast­user­switching soMarge can log in.Because Homer is in the audio group, he has still access to the audio device. If some software,e g PulseAudio, has the audio device opened, it blocks access to other software trying to use it.Now Marge has an audio issue!

I’ve written a longer article about the audio group here. In short, there are some usages for it,including that it is also the standard group name for assigning realtime priorities when used togetherwith JACK. But don’t leave a user in the audio group unless you have a good reason.

4. Don’t try different “model” strings

A common way to try to get HDA Intel soundcards to work is to edit /etc/modprobe.d/alsa­base.confand add the following line:

options snd-hda-intel model=[something]

Page 10: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 10/25

options snd-hda-intel model=[something]

…where [something] are values you find in some file. Contrary to official documentation, this is inmost cases obsolete. In particular, avoid model=generic – that is almost guaranteed to give youtrouble. In many cases, when trying different models, you will find that you might fix one thing butbreak another.In fact, there is only one model to try, and that is model=auto. If your machine happen to be one ofthose quirked to use an older model parser, changing to model=auto can improve the situation.

Instead do:It still happens that BIOS/UEFI assigns the wrong values to pin nodes, which causes an output orinput not to work correctly. If so, I recommend trying to tweak this with hda­jack­retask.In some cases, trying different modules can actually be okay – sometimes, these models point tolightweight fixups instead of the earlier, more heavyweight code that was used in previous kernels. (Inthis context, I have to mention that Takashi Iwai has done a fantastic job of converting the oldermodels to the newer auto­parser.)

3. Don’t upgrade ALSA drivers by following random blog posts

I’ve seen far too many people reporting bugs on Launchpad where they’ve been following somerandom blog post that tells you how to upgrade ALSA, and are having audio issues as a result. Theseguides are of varying quality and often come without good uninstall instructions, so you have no wayto revert in case the upgrade did not solve your problem, or broke something else.

First, something not everybody is aware of: 95% of ALSA code is in the kernel, and follows thekernel’s release cycle. That means that even if “/proc/asound/version” says something that wasreleased a year or two ago, don’t panic. It’s the kernel release that tells you how new your sounddrivers are, so if you have a new kernel, and you see an ALSA release coming out, you are unlikelyto gain from an upgrade.

Instead do:In some case you do have an old kernel, and newer sound drivers can be worth a try. The UbuntuAudio Developer’s team provides daily snapshot drivers for HDA Intel cards. Guide is available hereand it also comes with proper uninstall instructions.In the past we have also provided drivers for other cards, but due to the maintenance required to keepthis up­to­date, in combination with that the vast majority of people’s bugs concern HDA Intelanyway, this support has been discontinued.

2. Don’t purge PulseAudio

First, PulseAudio itself isn’t perfect, some of the bindings to PulseAudio aren’t perfect, and some ofthe drivers are not perfect in the way PulseAudio wants to use it either. So there might be validreasons to temporarily move it out of your way, even if it would be better to actually fix the problemand submit a bug fix patch (if you’re capable of doing so).But don’t try uninstalling the PulseAudio package, as it has far too many dependencies.

Instead do:If you just need direct access to your sound card, you can run the “pasuspender” command. You caneither run “pasuspender” (in a terminal) to make PulseAudio stay away for the duration of theapplication. Or if you think that’s simpler, just run “pasuspender bash” (in a terminal), start yourapplication through the menu/dash/whatever you prefer, and when you’re done, write “exit” in theterminal.If you need to stop the PulseAudio process completely, execute these commands:

echo autospawn=no > ~/.pulse/client.confpulseaudio -k

If you need PulseAudio back again, remove ~/.pulse/client.conf, then try to start an application thatuses PulseAudio, and it should start automatically.

Unexpected side effects:

Page 11: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 11/25

Unexpected side effects:

The Gnome sound settings, the sound indicator and the volume up/down keys relies onPulseAudio, so they won’t work when PulseAudio is off.PulseAudio mixes audio, so that means that only one application at a time can output audio ifPulseAudio is disabled (and you aren’t using some other sound server).Several applications have PulseAudio backends. Some of them will need reconfiguration to useALSA directly, some will just automatically redirect themselves, and some won’t work at all.Bluetooth audio might not work without PulseAudio.

1. Don’t replace ALSA with OSS

OSS was the standard used before ALSA came along. These days, ALSA is much better, both whenit comes to hardware support, and when it comes to how much software that supports outputtingsound to either sound system. OSS is also entirely unsupported, at least by Ubuntu. In addition, I’mnot sure exactly how to get back to a working system after you’ve tried OSS…!

Instead do:If you know your problem is in ALSA, either drivers or userspace, try to track down and/or fix thebug, and talk to us about it. If you’re running Ubuntu, file a bug against the alsa­driver package. Youcan also contact the alsa­devel mailinglist. While we won’t guarantee responses due to the highvolume of bugs/traffic, we are often able to help out.

Final notes

Note 1. HDA Intel cards are the built­in audio inputs and outputs on your motherboard (at least if youbought your computer after ~2006 or so). HDMI and DisplayPort audio are also HDA Intel cards, butthey are covered in more detail here.

Note 2. I have had some problems with spammers posting spam comments to my blog post. I don’twant to spend too much time just reading spam and marking it as such, so I might close for commentsin a relatively short period. Sorry for the inconvenience.

David Henningsson

Three audio bugs that need your hardware info

May 22nd, 2012 by David HenningssonCategories: PulseAudio, Uncategorized3 Comments

Are you:

Missing speakers or internal mic in sound settings?Seeing a S/PDIF device show up for your USB device?Having no or extremely low sound from your internal microphone?

If so, I might need your help to be able to fix it for you!

In Ubuntu 12.04 – and very likely, other recent distribution releases as well – there are at least thesethree audio bugs that need manual quirking for every machine. This means that you submit yourhardware info in the meta­bug, I will look in that info for some ID numbers and include them in a listof devices for which a specific workaround has to be applied. We can’t apply the workaround forevery device, as that could potentially cause problems for other devices.

So if you’re suffering from one of the bugs I’m describing below, I could use your help to make surethey are fixed for future releases of Ubuntu and ALSA/PulseAudio.

Missing speakers or internal mic in sound settings

Page 12: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 12/25

Missing speakers or internal mic in sound settings

If you’re suffering from one of the following problems:

1) In the sound settings dialog, when you plug your headphones into the designated 3.5 mm jack,there is a “Headphones” device correctly shown, but when you unplug it, there is no “Speaker”device shown, even though you have internal speakers on your computer.

2) In the sound settings dialog, when you plug your external microphone into the designated 3.5 mmjack, there is a “Microphone” (or similar) device correctly shown, but when you unplug it, there is no“Internal Mic” device shown, even though you have an internal mic on your computer.

Then you might be suffering from bug 946232. Please look in that bug for your device in that list, andif it is not there, try the workaround and if it’s working, add your alsa­info as suggested in the bug.Thanks!

S/PDIF device showing up for your USB device

If you have a USB headset, or another USB device that does not have any S/PDIF output, but yetsometimes there is an extra device called “Digital Output (S/PDIF)” for that device in SoundPreferences. If so, you’re likely suffering from bug 1002952. At the time of this writing there are alsoa few devices that are on their way to becoming fixed, if you have one of these, please help out withtesting the proposed repository. There is more information in bug 1002952 about that.

Inverted Internal Mic

In this case, you have an internal mic showing up, but it seems not to work: it’s either completelysilent, or you can possibly pick a very small sound, with much background noise, even though youhave set gain to maximum.

There is something you could try. Install the pavucontrol application, start it and go to the “InputDevices” tab. Unlock the channels (click the keylock icon), then mute the right channel while keepingthe left channel at the volume you want.If the internal mic is now working correctly, you have an inverted internal mic, so that your rightchannel cancels out the left one. (Why the hardware is constructed that way is beyond me.)This seems to be most common on Acer Aspire laptops, but I’ve seen them on other laptops as well,and fixing these are more of a long term project as they are non­trivial kernel patches. So far I’vecreated a patch for Thinkpad U300s. Anyway, I would like to track the remaining ones in bug1002978, so please add your system there according to the instructions.

Last but not least – thanks in advance for helping Ubuntu, as well as the greater Linux ecosystem (I’llmake sure that the patches pushed into Ubuntu gets upstream as well)!

David Henningsson

Audio over HDMI and DisplayPort in Ubuntu 12.04

April 14th, 2012 by David HenningssonCategories: PulseAudio, Uncategorized5 Comments

Ok, for those of you who just want it up and working, I’m including a quickstart section before wedive into the details:

Quickstart

1) If you have an ATI/AMD or NVidia card, you need proprietary drivers.2) You need to activate your secondary screen. For Intel, this is done in the regular “Screens” dialog,and on NVidia this is done in the nvidia­settings dialog. (I haven’t tested fglrx.)3) You need to select the HDMI/DisplayPort output in the sound settings dialog, which is quickest

Pages

About

Archives

August 2013April 2013January 2013November2012October 2012July 2012May 2012April 2012December2011

November2011September2011

Labels

Page 13: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 13/25

3) You need to select the HDMI/DisplayPort output in the sound settings dialog, which is quickestreachable from the sound indicator.

Can’t we switch audio output automatically?

Choosing whether to automatically switch to HDMI/DisplayPort – essentially, switching sound to usethe HDMI/DisplayPort whenever that screen is activated – is not trivial. It is not obvious to mewhether the user wants to do that, or not. And in fact, in Ubuntu 11.10, we did switch, but only forsome cards. And we did not switch back when the screen was deactivated. After a discussion wheredifferent opinions were voiced, I reached the conclusion that given the current pieces of infrastructurein place, the best option would be to disable automatic HDMI/DisplayPort switching for Ubuntu12.04.

The problem of four devices

As mentioned in an earlier post, much HDMI/DisplayPort hardware have phantom outputs, and thereis no way we know what outputs are real until something is plugged in. With the new sound settingsUI in Ubuntu 12.04, we finally have a good user experience in this scenario: Only the outputs that areactually plugged in and possible to activate will be shown.

Sound settings in Ubuntu 12.04

Video drivers

Most of the code to activate HDMI/DisplayPort audio is in the video driver, rather than the audiodriver. Therefore, if this is not working, it is more likely that the problem is within the video driver.It is also notable that the open source driver for ATI/AMD (called radeon), has experimental supportfor HDMI/DisplayPort audio, at least for some cards. It is disabled by default, but you can activate it

by adding radeon.audio=1 as a kernel boot parameter.

Upstreaming notes

PulseAudio 2.0 is soon to be released (hopefully). PulseAudio 2.0 and Ubuntu 12.04 have the samefeature set when it comes to HDMI/DisplayPort audio support.The new sound settings UI in Ubuntu 12.04 has not yet been upstreamed.

David Henningsson

Audio debugging techniques

December 8th, 2011 by David HenningssonCategories: PulseAudio, Uncategorized

Labels

PulseAudio(8)Uncategorized(8)

Page 14: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 14/25

Categories: PulseAudio, Uncategorized6 Comments

As a part of the Ubuntu Hardware Summit, I held a presentation on the topic “audio debuggingtechniques”, focused on HDA Intel cards. I also wrote down some notes for some of those slides. Ishare the slides and the notes with the hope that you will find the information useful if you run intotroubles with your audio hardware.

Audio stack overview

The audio stack can seem a bit complex, but first look at the line all the way from the applications to

the hardware. This is the optimal audio path. If the audio path is different, complexity will increaseand you might run into undesired behaviour, such as one application blocking another from playingaudio. There are valid exceptions though – we have a separate sound server for professional, low­latency audio. But that’s outside the scope of this presentation.

Let’s start from the top. On the top we have different kinds of audio applications, which talk toPulseAudio. GStreamer is a library to help media playback, it can for example decode ogg and mp3files. PulseAudio mixes these audio streams and send them down to the kernel. The ALSA libraryand the ALSA kernel core do not do much here but send the audio pointers through. The HDAcontroller driver is responsible for talking directly to the hardware, and so it sets up all necessaryDMA streams between the HDA controller and memory. The HDA controller driver also talks to theHDA codec driver, which is different for every codec vendor.

As some of you probably know, between the HDA controller – which is a part of the southbridge inmost computers – and the HDA codec, a special HDA bus is used. This means that the only way wecan talk to the codec is through the controller.

Controlling audio volume goes the same path. When you use your volume control application, itcontrols PulseAudio’s volume. PulseAudio in turn modifies the volume controls being exposed by thekernel, and the kernel in turn talks to the hardware to set volume control registers on the codec. Thereare two levels of abstraction here: first, the kernel might choose not to expose all of the hardware’svolume controls, and second, PulseAudio exposes only one big volume control which is the sum ofsome of the volume controls the kernel exposes. So there is filtering on two levels.

Page 15: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 15/25

Audio stack overview – codec

Let us have a look at the HDA codec chip and how its internals are represented to the driver. Thecodec is constructed as a graph, and on this slide one of the more simple HDA codec graphs is shown(just because it would fit the screen). A while ago upstream made a small program to extract thisgraph from the codec and make a picture of it. Thanks to Keng­Yü, who works for Canonical inTaipei, this tool is available as a package in Ubuntu 11.10. Just install the “codecgraph” package.

In this graph we have nodes correspondings to DACs, ADCs, mixers, and pins. In this example wecan see what pins are connected to which DACs by following the solid line. The dotted line shows a

Page 16: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 16/25

connection that is possible but not currently active.

As the Linux codec driver code grows more intelligent, we depend more and more on thisinformation to be accurate. This way we do not hard code as much in the driver, so we can adapt tofuture codecs without having to rewrite much code.The information coming from the codec is usually correct. One problem we have from time to time isthough, is that sometimes chip vendors add features which they choose not to document in this graph(and not in any other way either). There is a mechanism called “processing coefficients” in thespecification, where the vendor can add its own functionality without telling anyone. When thathappens, and it is required to use these undocumented “processing coefficients” to enable all inputsand outputs, we usually run into difficult problems that require vendor support to resolve.

Also, in some cases the graph cannot describe the functionality needed, e g if some hardware isdepending on special pins on the codec. We need to know about this when it happens, so we cansupport it in the driver. So if you are a hardware designer, my message is: Try to use the standard wayof doing things as much as possible. Do this and it will work out of the box on Linux, and likely otheroperating systems as well. If you do anything special, you’re causing headache for driver writers,

possibly causing a slower time to market.An example of this would be how you control external amplifiers: you can use the EAPD pins, whichis the standard way, and you can use GPIO pins, ACPI, or anything else, that will be moreproblematic and require special driver support.

Pin configuration default

We also depend on information from the writers of BIOS/UEFI, i e the computer’s firmware. As ahardware designer, you have the freedom to choose which pins of the codec that go to what physicaljack. You might decide that you want a digital out, or you decide that this machine should not havethat functionality, and then you leave that pin unconnected.Then the firmware engineer needs to know this, and program this into the codec when the computerboots. This is done by setting the “Pin Configuration Default” register. This register tells us not onlythe device type (headphone, mic, etc), but also the location (Internal, External, Docking Station), thecolor, and the channel mapping (to use for surround functionality).

Several years ago, we did not read this register much, but these days, we depend on that for all new

Page 17: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 17/25

Several years ago, we did not read this register much, but these days, we depend on that for all newcomputers for setting up the codec correctly. So what do we do if this register is wrong? Well, if wework with hardware pre­release, there might be a chance we can feed this information back to thefirmware writers so they can correct the problem. If the hardware is already released, we have tocreate a “quirk”. This means that the driver overrides the firmware’s pin value(s) and instead uses itsown value.

Because this value is so important, I’ve written an application where you can try out differentcombinations of this register.

Mixer problems

One of the most common problems with getting audio up and running on Linux is to make sure themixer is correct. Typical symptoms of this would be that some outputs are working where others arenot, or that there is something wrong with the volume control.

Here are some initial checks of these problems. We do this at the two levels of mixer abstraction.First, let’s have a look at the PulseAudio volume control. You can do that in Gnome’s volume controlapplication.

Also, PulseAudio controls the volume of mixers at the ALSA level. You can see how this works bystarting the alsamixer program. In this program, you can also see additional sliders, which you canalso use to verify that they are in the correct to enable sound. You start alsamixer from a terminal (inUbuntu the quickest way to launch a terminal is the Ctrl­Alt­T shortcut).

Mixer control names

Page 18: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 18/25

So let’s look at these two abstraction levels in more detail and how you can inspect what is actuallygoing on. First, let’s look at the codec level. If you are familiar with the codec’s nodes and how theyare connected, e g by running “codecgraph”, you can also find out which ALSA level controls thatare connected to which nodes on the codec. This is done by inspecting the “codec proc” file. Everycodec in the system has this file, and its name is made up of the sound card name, and the codec’saddress on the HDA bus. In this file, you can also see a lot of other information about the codec.

So next, we will also take a look at PulseAudio’s abstraction of these controls. This is done bylooking at the files in /usr/share/pulseaudio/alsa­mixer. In this case, if we look at/usr/share/pulseaudio/alsa­mixer/paths/analog­output­headphones.conf, you can e g find the sections[Element Master] and [Element Headphones]. That means that the ALSA­level controls “Master” and“Headphones” are being merged in PulseAudio’s volume control when the “Headphones” port hasbeen selected.

So these two places are the keys to understanding what is going on when you have mixer problems.

PCM/Streaming problems

Page 19: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 19/25

So up next is when you have problems with the streaming. That is usually shown as the audio isbreaking up, crackling or glitching. Unfortunately these problems are typically quite hard to resolve.

Sometimes this can be a bug in PulseAudio, or in the driver. But more often the problem is on eitherthe application side or the hardware side.

If an application is not submitting data to PulseAudio in time, the PulseAudio has no audio to playback, so therefore playback breaks up. Once some more data has reached PulseAudio, it startsplayback again, and so playback is started and stopped repeatedly.

The other problem could be with bad position reports from the hardware. PulseAudio depends onbeing able to ask the hardware for its current position at all times, and this should be sample accurate.You can test this by trying to run PulseAudio with timer scheduling disabled, in this case PulseAudiowill rely more on DMA interrupts and less on position reports. However, this will also makePulseAudio draw more power than necessary from the machine, so please avoid this if you can.

When I try to debug these problems I usually start with making a PulseAudio verbose log. It oftentakes some knowledge and experience to be able to analyze this log though.

Jack sensing

Page 20: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 20/25

Over the last six months or so, one of the things I’ve been working with is trying to get better jackdetection handling, throughout the audio stack.“Jack sensing” in this context means what to do when something has been plugged in, or unplugged.

When this happens, an interrupt (IRQ) is triggered and control is passed to the HDA codec driver.The driver takes the first action itself. Now, this is an area, unfortunately, when things differ a lotbetween different drivers, mostly between different vendors, but also between different chips of thesame vendor, or even between configurations of the same chip.

But as a general rule, and for the most common vendors – that means Realtek, IDT and Conexant –these rules are the ones that are followed:

For headphones – when you plug them in, the Internal Speakers are muted. Remember, this isstill all at the kernel level.For what we’re doing with Line Outs – it’s not completely standardised everywhere yet, but itseems upstream is leaning on having Headphones mute Line Outs and having Line Outs muteInternal Speakers by default. Some drivers also have a special control where the automutebehaviour can be changed.For Microphones – the only rule here is that if we have only one internal microphone and oneexternal microphone, the external microphone takes over when you plug it in, and the internalmicrophone regains control when you unplug. Should there be any other inputs, e g twoexternal mic jacks, or a line in jack, no autoswitching is done at the kernel level.

After this has been done, a signal is sent to userspace. Hopefully – this also varies between vendors.We’ll get back to that. What’s new in Ubuntu 11.10, is that this signal is being picked up by

PulseAudio. This is important, because it enables PulseAudio, to switch port for volume control. Sothis means, when you press your media keys (or use the sound menu) to control your volume, youcontrol your headphone’s volume when you have headphones plugged in, and your speakers’ volumewhen your headphones are unplugged.

So this not working properly, is one of the more common problems. I have written a small tool thathelps you to debug whether this issue is in hardware or software. This tool is called “hda­jack­sense­test”. This program sends the “get pin sense” command to each codec and outputs the results. Iactually had use for it earlier this week, and confirmed that it was a hardware issue: although theheadphones were unplugged, the “get pin sense” command returned that the headphones were beingplugged in and unplugged all the time.

If you can confirm that things are working at this level, you can also look in “Sound settings” to see ifthe port (this is known as a “connector”) is automatically switched whenever headphones – ormicrophone – is plugged in. If it is not, the most common cause is that kernel driver does not notifyuserspace correctly about that change.

HDMI/DisplayPort Audio

Page 21: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 21/25

One of the most common problem with HDMI these days are with newer chips supporting more thanone output. These outputs could be HDMI, DisplayPort or DVI (with audio supported through a DVIto HDMI adapter). NVidia has supported four outputs for quite some time and Intel has supportedthree. But usually, not all of these are actually connected on the board.Now, the problem is: How do we know what pin to output to? And the answer is, that there is nogood way to figure that out until something is actually plugged in.

If you remember me talking about the pin config default earlier, you would say that maybe thegraphics chip could mark the pins not connected to anything. If this was done, it would be a great start(and if they are, we make use of it to hide the outputs that are marked as not connected), butunfortunately, more often than not, these pins are set up as all pins connected and present. So if youwrite firmware for internal or external graphics cards, please do set up these pins.

So if we don’t know, what do we do? Well, here’s also work in progress at the userspace level. First,PulseAudio has to probe how many ports there are. Then we can use the new jack detection feature,to determine what has actually been plugged in. I’m currently working on redesigning the soundsettings dialog so that the ports that are not plugged in will be actually hidden from the dialog, and Ihope this will land in Ubuntu 12.04 which will be released in April next year.

And a final note, just so you don’t forget it: For NVidia and ATI, they both require proprietary videodrivers to enable HDMI and DisplayPort audio. The ATI driver used to have support for some of thecards in its open source driver, but this feature was recently removed because they had some problemswith it.Intel has no proprietary drivers at all, so there it works with the standard open source driver.

Page 22: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 22/25

Page 23: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 23/25

David Henningsson

Turn your mic jack into a headphone jack!

November 29th, 2011 by David HenningssonCategories: Uncategorized18 Comments

Most of today’s built­in sound cards are to some degree retaskable, which means that they can beused for more than one thing. That means you can turn your Mic jack into an extra Headphone jack,or why not make them both line outs, and connect them to your surround receiver?

I’ve known for a while that the kernel exposes an interface that makes it possible to retask your jacks,but almost no one seems to use it, or even know about it. So over the past few weeks I’ve beenworking (from time to time) with HDA­Jack­Retask, a small application that makes this interface easyto use.

Although primarily meant for power users, it focuses on simplicity: Just select your codec, then selectwhich pins you want to override and what you want them to override to: Headphones, Line Out, Mic,Line In, and so on. There are buttons for trying it out right away, and for making your override theboot­time default. And of course, a button for removing all overrides in case things did not go asplanned.

Consider it beta quality for now, and it’s one of those “won’t work for everyone” programs, but that’smostly due to hardware and driver limitations.

It’s available for Ubuntu 11.10, and you can install it by adding ppa:diwic/hda and then installing thehda­jack­retask package. Start it by running “hda­jack­retask” in a terminal. Enjoy!

Page 24: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 24/25

« Older Entries

About Canonical

What we doCanonical and open sourceCareersPartnershipsNews and eventsContact

About Ubuntu

Ubuntu for businessUbuntu for youUbuntu and educationCase studies

Enterprise services

Ubuntu AdvantageTrainingConsultancy

Engineering services

OEM servicesCertificationCore engineering

Consumer services

Ubuntu OneSupportTraining

Page 25: Turn Your Mic Jack Into a Headphone Jack

12/10/2013 David Henningsson « A better sounding world

http://voices.canonical.com/david.henningsson/author/diwic/ 25/25

Further information

News and eventsCareersLegalNews feed

© 2010 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.