HD Audio to AC97

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
bigbob
Member
Member
Posts: 122
Joined: Tue Oct 01, 2013 2:50 am
Location: Budapest, Hungary
Contact:

HD Audio to AC97

Post by bigbob »

Hi,

I have managed to understand and program AC97 according to:
http://useruploadedfiles.programmersheaven.com/23237/
Unfortunately new computers have HD Audio only, so having AC97 programmed is not a great thing.
However it seems that the HD Audio controller can be set to AC97 mode by clearing bit0 of the Intel High Definition Audio Control Register (page 22 in io-controller-hub-7-hd-audio-ac97-manual.pdf and also the diagram on page 109 in the same pdf).
HD Audio is very complicated, so it would be great to skip it.
It's not mentioned in the wiki, that HD Audio controller can be set to AC97:
http://wiki.osdev.org/Intel_High_Definition_Audio

Does clearing that bit mean to have an AC97 controller on a machine with HD Audio? And will the code written for AC97 work using D30:F2 instead of D27:F0 (HD Audio)?
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: HD Audio to AC97

Post by DavidCooper »

The only mention of AC'97 in the High Definition Audio Specification is with the following paragraph:-
1.2.1 AC‘97 Compatibility

The High Definition Audio architecture was not developed with the intent of being backward compatible with AC'97. Unlike AC'97, the primary goal of the High Definition Audio Architecture is to develop a uniform programming interface and to provide fundamental flexibility and capabilities beyond those supported by AC'97. Therefore, the High Definition Audio architecture and specification must be considered entirely a separate specification from AC'97, implying no backward compatibility. Specifically, link protocol and operation between these two specifications is not compatible. AC'97 and High Definition Audio codecs cannot be mixed on the same link or behind the same controller.
The last bit of that suggests that it cannot share D27:F0. On the machine I normally program on (a netbook) there is no AC'97 controller at D30:F2, but my notes (on the back of an envelope) suggest that another machine which I tried my OS on had both an HDA controller at D27:F0 and an AC'97 controller at D30:F2. Bit 0 of 40h (HD Audio control register) must be set to 1 for HDA or to 0 for AC'97, but I think setting it to 0 simply disables the HDA machinery so that it doesn't conflict with the AC'97 stuff which probably needs to have its own controller at D30:F2 if it exists on the machine at all.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
bigbob
Member
Member
Posts: 122
Joined: Tue Oct 01, 2013 2:50 am
Location: Budapest, Hungary
Contact:

Re: HD Audio to AC97

Post by bigbob »

Thanks David! This is what I suspected :oops:
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: HD Audio to AC97

Post by DavidCooper »

Don't be scared of taking on HDA. It's fairly straightforward, apart from the complication that codecs can vary widely in design. Your code has to be capable of exploring the codec hardware to work out how all the widgets are connected together so that it can set up paths between the right ones. You can cheat at first by getting the datasheet for the codec on your machine to make sure that you succeed with that one, then look at other datasheets for other codecs and adapt your code where necessary so that it can handle them as well, though you don't want to program your driver with a knowledge of those specific codecs, but instead give it the necessary capability to work out how to use them for itself. You can get your driver to produce a list of widget connections which a user of a machine can send back to you if your driver is unable to link things up correctly (as well as getting the ID for it so that you can try to get hold of the datasheet if it's available) - that would enable you to draw up a map of it and to work out where your code is failing to solve the puzzle. I haven't tested my own HDA driver widely yet due to other bits of my OS needing to be made safe before I release a new version, but there's also the issue of trust to overcome before people are prepared to run your OS directly on their hardware, so I'm thinking of writing a stripped down minimal OS + HDA driver just to test that on its own, the point being that it will be easy for the user to check the content and be certain that it's safe.

This might actually make the basis of a good competition (without a prize - no need for one as you end up with the essentials of a working HDA driver) to see who can get a machine to record and play back sound (using internal mic. & speakers and mic. jack & headphone jack) using the minimum number of sectors: it would only need to boot, load the rest of the code it needs (from flash drive so that it can be tested easily on lots of different machines), set up the HDA codec and then demonstrate that it has done it correctly by recording and playing back sound. This would help people find out how well their code is able to handle different codecs and to fix it if necessary until it can handle them all (or at least all the ones we can collectively throw at it).
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
bigbob
Member
Member
Posts: 122
Joined: Tue Oct 01, 2013 2:50 am
Location: Budapest, Hungary
Contact:

Re: HD Audio to AC97

Post by bigbob »

A good advice :)
A wasn't even reading the right datasheet because there seems to be an even more important one(High Definition Audio Specification):
http://crashrecovery.org/hdaudio_pdf/Hi ... o_1_0a.pdf
More than 200 pages...
But this one is also necessary(Intel I/O Controller Hub 7 (ICH7) / Intel High Definition Audio / AC'97 ; Programmer's Reference Manual):
http://www.intel.com/content/www/us/en/ ... anual.html

EDIT: To me it looks like the HD Audio is a "super" (or complicated) AC97, so it is not a waste of time to understand and play with AC97 even for a developer of HD Audio.
User avatar
DavidCooper
Member
Member
Posts: 1150
Joined: Wed Oct 27, 2010 4:53 pm
Location: Scotland

Re: HD Audio to AC97

Post by DavidCooper »

AC'97 is certainly not a waste of time. I intend to write a driver for it some day because there's plenty of life left in the older machines that use it, but it does take a lot of time to read the specification for these things and to make sense of them. I just happen to have done the work for HDA first while you've done AC'97 first, and we're now both a little reluctant to put in the effort to do the same again with the other because we know how much work is going to be involved, but by sharing information we can help each other to get the job done much faster.

Making a minimal OS + AC'97 driver in as few sectors as possible would be just as useful a challenge as doing it for HDA, creating simple examples of how these devices can be set up and used so that others can use them as an initial guide to writing their own, as well as making it easier to get other people to test it on their machines. I'm certainly going to do this for HDA and will provide a document along with it spelling out in clear language what is being done at each step and how. I'll post a link to it here when it's done, but I can't say when that'll be.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
Post Reply