Skip to main content
Home Forums Taking another shot at onboard audio on a Mac Mini G4? Taking another shot at onboard audio on a Mac Mini G4?
Thread

Taking another shot at onboard audio on a Mac Mini G4?

Taking another shot at onboard audio on a Mac Mini G4? Development 10 posts Apr 20, 2007
That was a super useful breadcrumb to follow.  I didn't know about the SDKs.  On Macintosh Garden, I found the Apple Developer Connection 1996, and the December issue (reference library) contains article #20 which contains an article on how to write a sound output component, along with some sample code.

Note that I had to open this on an old Intel MacBook Pro running Mojave; my usual M1 MacBook Pro on Ventura won't mount HFS.  Anybody know a way around this, for CD images and DMGs?
A few more updates here.  So looking at the Open Firmware screenshots I posted earlier, the only thing in the .properties for the sound device was "name pseudo-sound".  That doesn't match what the Linux driver expects.  So I reset Open Firmware (reset-nvram, set-defaults, and then reset-all) and found that the full device showed up, as AOAKeylargo and with the expected layout-id.  So something is happening where the OS 9 audio driver removes the sound device from the device tree.

As a test, I removed the Apple Audio Extension, and while the onboard output doesn't show up in the Sound preference panel any longer, sound output still works, and the Open Firmware sound device still ends up renamed after a reset.  So perhaps the sound driver built into the System file is doing this?

Also, any ideas on where to set a breakpoint so I'll drop into MacsBug when an application plays a sound?  I tried "tvb SndPlay" and it sets the breakpoint, but I never see it hit.
After reading https://vintageapple.org/inside_r/pdf/Sound_1994.pdf some more, I found that I can hit TVect breakpoints at SndDoCommand and SndDoImmediate when I run an application that plays sound (Spin Doctor, for instance).  However, I can't single-step through what happens to try to figure out which sound output component is being used.  See the attached MacsBug screenshot -- I end up stuck with a bus error.  If I trace over some of the calls, I can go farther, but I still end up stuck eventually before I make it into a sound output component.

Any ideas what to do here?  Is this as a result of debugging in ROM, and if so, how do I skip over that?
I looked through the Component Manager documentation, and it seems that it really doesn't want to expose where to find the component. Thankfully, we have the source. Hopefully it isn't too outdated. If these struct definitions are still accurate, you can peek into the RegisteredComponentInstancePtr returned by OpenComponent and then grab its rtiEntry. From there, rtRoutine and/or rtRoutineHandle are probably where you want to look to get the entry point. You probably need to lock the handle in memory somehow so that it doesn't get moved around (Unless that gets done for you somehow?).
https://github.com/elliotnunn/supermario/blob/master/base/SuperMarioProj.1994-02-09/Toolbox/ComponentMgr/PrivateThingManager.h#L79-L112
Some Component Manger related apps:
- "Things!" by Gary Woodcock/QuickTime™ Development Team
- "Fiendishthngs" (has source code) from Apple
- "Reinstaller3" Apple Computer QuickTime 4.0 SDK
- "Thing Detective" from Unthinkable Research
- "Thing Reporter" from Unthinkable Research (free)

I think I was using these when I was reverse engineering the planb (video input of Power Mac 8500, 8600, etc.) video digitizer QuickTime component from Mac OS 9 68K to port to PowerPC and Mac OS X.
I found a page for the Linux sound drivers for PowerMac which mentioned similar issues with the sound volume with the Toonie chip (Mac mini G4) which may be solved with a new driver "snd-aoa":  https://wiki.debian.org/PowerPC/SoundCards.

In another thread, someone pointed to the fact that the patched ROM makes Mac OS 9 treating the Mac Mini G4 as a Cube which had no built-in amplifier for the sound volume because it was meant to run with special speakers (Apple Pro USB Speakers) which had itself the amplifier for sound: http://macos9lives.com/smforum/index.php/topic,2408.msg52465.html#msg52465.
Hi!

Sorry to unearth this topic but I had a strange behaviour with my Mini this morning.

I needed sound output for a quick test so I (re)tried to use a cheap USB audio adapter.
Once I connected the adapter, I got System sounds (mainly the ones from the OS theme) but no "standard" sound (from Quicktime Player or by playing an Audio CD in iTunes).
So I tried to reboot but with the adapter already connected.
Now, I got sound from my adapter.

OK but what's new ?

The first time, when I connected the adapter, it appeared in the Sound control panel.
When I restarted the mini, no adapter visible in the Sound control panel.

Does anyone have an explanation ??

Also ...  the control panel kept the "Main volume" to 0 even if I had sound in my speakers.  O_o
BUMP!

With all those programmers joining this place recently, it would be extremely cool if some of you could look at this issue.
It has a very high priority and, if solved, it would make many many people happy.

Thanks and keep decompiling! :)

P.S. Here's a bit more on this: http://macos9lives.com/smforum/index.php?topic=4325.0
I thought about this some more.  I went through the device tree and wanted to see if I could access the sound-related GPIOs directly through reads and writes to their physical addresses in Open Firmware.  It looks like the answer is yes.  See the attached screenshot -- this is reading the headphone detect GPIO directly, with the plug removed/inserted/removed.  It looks like bit 1 represents the GPIO detected state, which correlates with the Linux aoa sound driver I linked earlier in the thread.

I'm thinking of writing my own sound component to handle the GPIOs at first, and the I2S DAC eventually.

A few questions for folks who know more about this stuff on classic Mac OS than I do:

* If I write a sound component, are all the physical addresses for the available hardware identity-mapped within the component?  For instance, if I go read 0x80000067 like I did here, will it work?  Or do I need to do something like ioremap() on Linux?

* How do I register an interrupt handler for the GPIO interrupt here?  It's off of the mac-io (Keylargo), which is a PCI-connected device.
It would be nice to document all the efforts so far taken on the Mac Mini G4 onboard audio problem, so there is no need to redo investigations and findings, especially if the work stops and has to be restarted by another person.

I have collected some information on the problem which I would like to share with the people currently working on this to help their effort to tackle the problem.
  • Problem situation:
    • Mac OS 9.2.2 (v9 iso image):
      • Sound Manager (v3.6.7 / QuickTime 5.0.2)
      • Headphone Port:
        • shows up in Sound Panel
        • plays sound, but at a very low volume level
        • Volume level not adjustable
      • Internal Speaker:
        • does not show up in Sound Panel
        • no sound at all
    • Mac OS 7.6.1 CHRP (v0.2 iso image): [1.1]
      • Headphone Port:
        • shows up in Sound Panel
        • plays some sound (System Sounds are played, but no beep sounds in poping up alert windows)
        • Volume level adjustable(?) in Control Strip and Sound Control Panel
        • probably made work by setting a valid NVRAM by accident
      • Internal Speaker:
        • does not show up in Sound Panel
        • no sound at all
  • Hardware information (Mac Mini G4):
    • Chipset: Toonie
    • DAC only, no hardware functions (mixing, amplification, ...) so everything must be done in driver software [3,4,5]
    • devices: Line Out (Headphone Port), Internal Speaker [2]
  • Existing driver sourcecode for the Toonie chip
    • Linux driver AOA (Apple Onboard Audio) [3,4]
    • Darwin driver AppleOnboardAudio [5]
    Both drivers show that the Toonie chip is just a plain DAC with no hardware support functions, so everything must be handled by the driver software. The driver sourcecode has also some tables with hardware ports, GPIO and I2C assignments.
    A Mac OS 9 driver must be created by porting the existing driver sourcecodes. The Darwin driver might be very helpful since it must handle the (Carbon) Sound Manager, too.
  • Developer Documentation for creating a Mac OS 9 sound driver:
    • Grokipedia [6]:
      Overview article over the historical developments of the Sound Manager
    • Inside Macintosh [8]:
      • A sound driver must be written as a Sound Component for the Sound Manager.
        If extra functions are needed (e.g. separate volume settings for stereo L/R-channels) a Audio Component is needed, too.
      • The components must be loaded by the Component Manager at OS startup.
      • An example how to create a Sound Component for the Sound Manager is given in the develop article [12.2].
      • The Sound Manager 3.3 (= Mac OS 9.2???) has some new functions which are not covered in Inside Macintosh. There is a ADC article [9].
  • Open questions:
    • How to enable the Internal Speaker? We can only send audio to the Headphone port so far.
    • What is the device tree, interrupts and memory addresses of the audio hardware? We need a complete list before we can start creating a driver (Maybe the Darwin driver sourcecode can help here?).
    • Should we build the Darwin driver from sourcecode and experiment there to figure out the answers first? (existing driver = easier to use for debugging)


Ressources:
mp.ls