AC97 driver

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.
pradeep

AC97 driver

Post by pradeep »

On seeing Dex4u in this forum, i like to post something regarding AC97. Well there are lot of documents about SB but nothing could be found regarding AC97 (except the datasheet from intel). So could you explain the process of writing a sound driver. Because i just want to impress my friends who don't know anything about FLUIDs , IPC, VFS etc. Ok i figured out how to find the vendor id,device id and the registers associated with them. Most of us(me and my friends) are having intel motherboards with ich4 or 5. what next?
[offtopic] why are u often saying i am ASHLEY4 i am ASHELY4.Dex4u aka ASHLEY4 we know u man. Don't we?[/offtopic]
pradeep

Re:AC97 driver

Post by pradeep »

Many people seems to start with SB and then move on to AC97 since more text is available for programming SB. In my library there seems to be a book on Sound Blaster i have to go through it. But how to configure bochs for SB? Could you post those configuration lines. VMware seems to directly output to the host sound adapter itself. If somebody have written a driver for SB or AC97 you could share with us.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:AC97 driver

Post by Pype.Clicker »

well, i wrote routines in real mode for the SB pro last millenium, but that was ugly assembler. If you want them, they're still online, though ...

I also know there are couple of GPL products (including "midas sound system") that contain code for various soundcards (including AC'97 iirc).

I fear i couldn't help at configuring SB on bochs, however. sorry for that.
Dex4u

Re:AC97 driver

Post by Dex4u »

Basically once you know you got a AC97 sound card,(eg vendor ID device ID etc) it just a matter of swiching the right bits, with the right delays etc.
My sound drivers for Dex4u OS use a lot of function built into Dex4u and are not real drives, as such, as they just swich the sound on and volume up/down etc, for use with the cdplayer.

But here is some great code from a friend of mine (jeff), its a wav player for dos with built in drive for ac97, come with welcommented asm code, + someother code that may help, if you still want my drive code let me know.

http://www.dex4u.com/23237.zip
http://www.dex4u.com/ichsrc.zip

Hope this helps.
pradeep

Re:AC97 driver

Post by pradeep »

@Dex4u : I read 23237.zip already but how to adopt it for protected mode with paging. I have to use IRQ's but it is using polling concept. Another question how many buffers are you using to store PCM data and what size is it. That files assume ICH2. Should i modify anything for ICH4? ICH4 is compatible with other ICH's am i right. Do newer intel mbd's are also maintaining this compatibility. What is the ICH version of the latest mbd?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:AC97 driver

Post by Candy »

pradeep wrote: @Dex4u : I read 23237.zip already but how to adopt it for protected mode with paging. I have to use IRQ's but it is using polling concept. Another question how many buffers are you using to store PCM data and what size is it. That files assume ICH2. Should i modify anything for ICH4? ICH4 is compatible with other ICH's am i right. Do newer intel mbd's are also maintaining this compatibility. What is the ICH version of the latest mbd?
ICH is a hub concept. It contains more than just the AC97 card so don't count on any relation.

Try to consider mainly the AC97 card. SIS mainboards for AMD have them too, as do many others. That gives you a lot more support instantly.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:AC97 driver

Post by Pype.Clicker »

quoting floodle on Arstechinca forum:
AC97 is a generic specification defining the interface between a sound controller and codec. Many modern motherboard chipsets include an interface for an AC97 codec to provide a cheap way for manufacturers to add sound (or, with MC97-compatible codecs, sound and soft-modem functionality) to motherboards. So a motherboard that is advertised with "AC97" onboard sound probably uses the sound functionality of the host bridge, which is software-based and relatively basic, especially if your needs include positional audio in games. Almost certainly it can be disabled, and at worst it can coexist with any other sound device you install.

For the record, your Santa Cruz also uses an AC97 codec, a Crystal CS4299A. In fact, most consumer sound cards made nowadays do.
http://www.alsa-project.org/alsa/ftp/ma ... s/4297.pdf

http://www.intel.com/design/chipsets/audio/ac97r22.pdf
latest revision (2.3) dates from 2002 ...
Dex4u

Re:AC97 driver

Post by Dex4u »

pradeep wrote: @Dex4u : I read 23237.zip already but how to adopt it for protected mode with paging. I have to use IRQ's but it is using polling concept. Another question how many buffers are you using to store PCM data and what size is it. That files assume ICH2. Should i modify anything for ICH4? ICH4 is compatible with other ICH's am i right. Do newer intel mbd's are also maintaining this compatibility. What is the ICH version of the latest mbd?
First i do not use paging in my OS, as for IRQ's theres a bit you enable to use IRQ you have full detail in the pdf.

For ICH4 you need to test for "24c5h" as the device ID
I have found ICH2 to be compatable with ICH4.
Here is a bootable CDplayer with basic AC97 dirver you can test to see if it works with your card, just click on the the exe with a floppy in the A: drive to make a bootable disk.
http://www.dex4u.com/AC97CdPlay.zip
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:AC97 driver

Post by Candy »

Dex4u wrote:
pradeep wrote: @Dex4u : I read 23237.zip already but how to adopt it for protected mode with paging. I have to use IRQ's but it is using polling concept. Another question how many buffers are you using to store PCM data and what size is it. That files assume ICH2. Should i modify anything for ICH4? ICH4 is compatible with other ICH's am i right. Do newer intel mbd's are also maintaining this compatibility. What is the ICH version of the latest mbd?
First i do not use paging in my OS, as for IRQ's theres a bit you enable to use IRQ you have full detail in the pdf.

For ICH4 you need to test for "24c5h" as the device ID
I have found ICH2 to be compatable with ICH4.
Here is a bootable CDplayer with basic AC97 dirver you can test to see if it works with your card, just click on the the exe with a floppy in the A: drive to make a bootable disk.
http://www.dex4u.com/AC97CdPlay.zip
Distributing exe files is very not nice to people who don't run windows (or who don't trust the exe in their windows environment). I'm not unhappy about you distributing an image, but a plain image would be more usable for a lot of people.
Dex4u

Re:AC97 driver

Post by Dex4u »

@Candy, your right it would be more usefull to some people, so any such people who want a image let me know and i will make and post a link to one.
pradeep

Re:AC97 driver

Post by pradeep »

iirc, ICH2 is compatible with ICH0,1. That means the driver written for 845 will also work on 815 (ofcourse registers specific to ICH4 shouldn't have been used). I am stick to Intel mbd only

In real hardware, IO addr for NAMBAR and NABMBAR registers and IRQ are may be set.IRQ should be set.
Buffer Descriptor List with 32 entries is created and LVI reg is set.
Run/Pause bit is set to 1.

My problem is that my IRQ is not firing now.
Is there any way to verify whether the code is working properly?
pradeep

Re:AC97 driver

Post by pradeep »

Since i don't have any chance with my AC97 sound driver, i am resurrecting this thread once again, If some body have written a driver for AC97 you may probably share with us, Or you might atleast give the steps to do it. Though the source code that Dex4u was pointing was much useful, they were written for DOS, i.e they are not suitable for paged OS. AC97 and ICH datasheet's are little hard for to follow. What do this meant by?
[tt]Buffers are usually passed to the driver as a list of desciptors that reference physical pages. These lists describe the physical page numbers associated with pages in the virtual audio buffer.[/tt]
Though this may be specific to the InTel motherboard, I couldn't get help anywhere. So somebody help me with this DMA programming.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:AC97 driver

Post by Pype.Clicker »

Well, quite simple: your driver has e.g. kalloc'd some memory for the audio buffer. That's nice. When it writes data to it, it uses virtual addresses ... but the I/O cards don't know about the processor's mapping, so you need to retrieve the physical page frame numbers (e.g. by looking up your pagetables for the virtual addresses you use) and build the 'descriptor list' with those values (rather than virtual addresses)
Dex4u

Re:AC97 driver

Post by Dex4u »

Also i can not help you as my OS is designed as a xbox or palm or moden Dos type OS (nopaging).

Here a link to Q&A that may help
alt.os.development link

[edit by pype + candy]long URLs screw up display[/edit]
pradeep

Re:AC97 driver

Post by pradeep »

Pype: Thanks a lot i have been building descriptors with the virtual address. Soon i will have my own AC97 driver.
Post Reply