Page 1 of 1

Concern about sound system

Posted: Tue Mar 24, 2015 1:37 am
by JulienDarc
Hello!

I dealt with learning the basics and have done quite a lot since then.
My next step is usb1.1 and sound.

I fear that audio is the hardest thing to implement.

I had a look at the linux sound system.
Obviously one can take ideas but i think that recreating a alsa system is.. Huge.
There is a need for only one or two devices so it is not as big but still the structure to follow is not clear.

Are there experienced users who could share their knowledge, feelings?

Thanks

Re: Concern about sound system in custom os

Posted: Tue Mar 24, 2015 2:49 am
by Kevin
Obviously, you can make a sound system as complicated as you like. But just getting something out of your speakers isn't that hard. You have to initialise the sound card and then feed it some buffer that contains the audio data (and keep feeding new data as long as you keep playing). Once you're there, you can start implementing additional features, e.g. adding a mixer, distinguish different outputs etc.

For USB, on the other hand, I'm afraid there aren't many shortcuts, so this might turn out harder than you think.

Re: Concern about sound system in custom os

Posted: Tue Mar 24, 2015 3:51 am
by JulienDarc
Thanks Kevin,

I already have all the reference for usb 1.1 and 2.0, and yes, it is *not* easy :)

Ok, so I am reassured as for the sound system.

Re: Concern about sound system in custom os

Posted: Tue Mar 24, 2015 6:07 am
by Kevin
If you need some simple driver code to compare to, you can have a look at the CDI drivers ac97 and hdaudio, which both do more or less the bare minimum. But if you know how to read specs, there isn't really anything new in the code.

Re: Concern about sound system in custom os

Posted: Tue Mar 24, 2015 6:14 am
by glauxosdev
You could also see TatOS usb related source code. My code (not released yet) is heavily based on it.

For ehci:
  • First you need to find the ehci controller on pci. Its address varies. Just use the bios to get it.
  • Then you need to initialize it.
    1. Get base address, operational base address, extended capabilities offset.
    2. Request ownership from the bios.
    3. Reset controller
  • Scan for devices (for now I recommend sticking with one device only).
  • Reset and enable the port that has the device connected.
  • Using control endpoint and address 0 get device-configuration-endpoint descriptors
  • Using endpoints got from endpoint descriptors, set unique address on usb bus. From now use only this address.
  • Similarly, set configuration.
  • Send inquiry command.
  • Test unit ready
  • Read capacity
  • Only then request Read10 / Read16 command
For uhci:
I have not implemented it yet. It is for low speed devices, and not flash drives.

PS. Why did you pose two completly different questions in one topic?

PPS. Also, there is no need for writing "in custom os" in your title. Everyone here knows you are making your own.

Re: Concern about sound system in custom os

Posted: Tue Mar 24, 2015 9:46 am
by JulienDarc
@Kevin : thanks for the pointer :)
@glauxosdev : you are right, specifying "custom" is stupid here ;) Two questions ? I am sorry about that I just wanted to ask about the sound system. The usb part was just to set the context. Your pointers are very interesting.
I, too for the moment, will stick with modern technologies because I know the machines the OS could run on.. one day.

Thanks a lot by the way !

Julien