Page 1 of 1

How to read the input from the microphone?

Posted: Sat Apr 14, 2018 6:09 am
by Klakap
Good day!
How do I read the input from the microphone? On osdev or on the forum, I found no instructions on how to make the support of the microphone. Please how do I do that?

Re: How to read the input from the microphone?

Posted: Sat Apr 14, 2018 6:30 am
by Korona
You probably need a driver for Intel HD audio devices or for some USB audio class. (But I have no experience writing a driver for either of those.)

Re: How to read the input from the microphone?

Posted: Sat Apr 14, 2018 11:35 am
by DavidCooper
On older machines you can use AC97 (although it's hard to support), but any machine modern enough to be worth programming for will likely use the more civilised Intel HD Audio instead, so your starting point should be to read this page of the Wiki: https://wiki.osdev.org/Intel_High_Definition_Audio. You may also need to read up on PCI (to find out what kind of sound card your machine supports). For USB microphones it's a lot more work as you also need to write USB drivers.

Re: How to read the input from the microphone?

Posted: Sat Apr 14, 2018 4:02 pm
by Brendan
Hi,
Klakap wrote:How do I read the input from the microphone?
Imagine that a computer is a tree of devices; with things like CPU and memory near the root node of the tree, and things like microphones at the end-nodes/leaves. Your question indicates that you're working from end nodes back to the root node; but it's better to work from the root node to the end nodes.

More specifically; it's better to do PCI bus enumeration, then choose a specific device in the list of unsupported devices that your software generated (e.g. maybe "vendor ID = 0x1002, device ID = 0xAA38", which corresponds to an "ATI RV710/730 HDMI Audio" device); then find the documentation for that specific PCI device and write a driver for it. While writing this driver you'll notice the device's documentation (hopefully) includes information about detecting and controlling attached devices (like speakers and microphones), so you'll naturally move one step closer to the end nodes in that part of the tree of devices.


Cheers,

Brendan

Re: How to read the input from the microphone?

Posted: Mon Apr 16, 2018 11:19 am
by Klakap
Please how do I implement the PCI into my OS? On the page https://wiki.osdev.org/PCI I found no code that would have something to read PCI.

Re: How to read the input from the microphone?

Posted: Mon Apr 16, 2018 11:29 am
by pat
Klakap wrote:Please how do I implement the PCI into my OS? On the page https://wiki.osdev.org/PCI I found no code that would have something to read PCI.
What are you having trouble with exactly? That page shows you exactly how to do PCI bus enumeration just like Brendan suggested. I mean there's even a function called pciConfigReadWord, which should answer "something to read PCI". The point of that article is to discover what devices are available. Then, like Brendan said, you can use the device id and vendor id to lookup the documentation for that specific thing, and then you make a driver for it.

Re: How to read the input from the microphone?

Posted: Mon Apr 16, 2018 11:38 am
by Klakap
Please how do I program the sysOutLong and sysInLong?

Re: How to read the input from the microphone?

Posted: Tue Apr 17, 2018 11:48 am
by Klakap
I have already resolve this problem, but I don't know where it is Header Type. Please tell me from where should I read Header Type.
//edit: Ups, I already noticed where it is Header Type :oops: .