Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: 1 [2]   Go Down

Author Topic: Taking another shot at onboard audio on a Mac Mini G4?  (Read 133759 times)

biggieshellz

  • 8 MB
  • **
  • Posts: 14
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #20 on: April 07, 2023, 06:49:34 PM »

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?
Logged

RossDarker

  • 256 MB
  • *****
  • Posts: 286
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #21 on: April 08, 2023, 02:06:52 AM »

There are various tools that can dump the contents of an HFS image such as machfs and hfsutils, however using them is a little different to mounting the image.

There is hfsexplorer to mount images in its own Java interface. Haven’t actually used this one before, but it looks good - I’ll probably visit it some time.

I have a slightly different approach though.
I attach the image as a CD/Drive to Mac OS 9 in Qemu/UTM, then work with it from there.
Either all the files can be viewed in the Mac OS 9 environment, or if some files need to be transferred to the host, another image can be used - a raw image that will show as a hard disk in the emulator, but can be mounted fully natively in macOS too.

This might seem like a long approach, but after setting everything up for the first time, the emulators start up pretty quickly these days. It does also feel like the most native way to me.


It’s really great to see the audio issue being tackled. Hope it all works out well, and many thanks for your work.
Logged

biggieshellz

  • 8 MB
  • **
  • Posts: 14
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #22 on: April 10, 2023, 12:40:32 PM »

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

Daniel

  • 256 MB
  • *****
  • Posts: 304
  • Programmer, Hacker, Thinker
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #23 on: April 10, 2023, 05:01:11 PM »

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
Logged

biggieshellz

  • 8 MB
  • **
  • Posts: 14
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #24 on: April 15, 2023, 08:18:08 PM »

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?
Logged

dtekle

  • 4 MB
  • **
  • Posts: 5
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #25 on: October 01, 2023, 07:06:08 AM »

Hello guys, was there any progress on this issue since April 2023?
If no, what is the roadblock and can other people help on this?
Logged

joevt

  • 128 MB
  • ****
  • Posts: 156
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #26 on: October 02, 2023, 03:10:14 PM »

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

ssp3

  • Moderator
  • 1024 MB
  • ******
  • Posts: 1033
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #27 on: October 02, 2023, 03:21:57 PM »

Hi joevt!  :)
It would be extremely cool if you, with your knowledge, could look into this Mac Mini audio thing. If you have time, of course.
Logged
If you're not part of the solution, you're part of the problem.

dtekle

  • 4 MB
  • **
  • Posts: 5
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #28 on: October 03, 2023, 09:54:21 AM »

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

zefrenchtoon

  • 64 MB
  • ****
  • Posts: 127
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #29 on: October 03, 2023, 12:22:44 PM »

Thanks to answer to my post @dtekle  :)


I've found the post talking about the "choice" of the Cube identifier in the modified ROM and it seems to confirm my worries as with another machine id, the sound was described as "coming out through speakers is either really loud or distorted".

http://macos9lives.com/smforum/index.php/topic,2408.msg30135.html#msg30135

Logged

zefrenchtoon

  • 64 MB
  • ****
  • Posts: 127
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #30 on: October 03, 2023, 12:46:47 PM »

I would be curious to test a ROM using the eMac machine code …  ;D

As we can see here, it seems to be close to the mini:

http://apple-history.com/compare/g4cube/mac_mini/emac_usb2/emac
Logged

dtekle

  • 4 MB
  • **
  • Posts: 5
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #31 on: October 05, 2023, 06:22:55 AM »

As far I can see the specs (http://apple-history.com/compare/g4cube/mac_mini/emac_usb2/emac) there could be some benefits but also some disadvantages by using the Gestalt of eMac vs G4 Cube:

eMac/2004:
+ almost identical specs to the Mac mini (same G4 processor PowerPC 7447, same GFX Radeon 9200, same ATA-100 interface, same WiFi)
+ no USB-amplified sound outputs
- original machine not able to boot Mac OS 9 natively
- slightly different audio output format (16bit vs. 24bit)
- eMac has audio input (is it a problem anyway?)
- different sound chipset ("Snapper" vs Mini's "Toonie")

The older eMac is maybe usable as base for ROM modding (instead using the Mac G4 cube), but there may be issues with the graphic card (can these be fixed with drivers?)

eMac/2002:
+ natively bootable with Mac OS 9
- hardware is one generation older (G4 7450, only ATA-66, older WiFI) (G4 cube's hardware is even older!)
- uses Nvidia GeForce2 as GFX instead of ATI Radeon

Can someone of the original ROM modder team have a look into creating a custon ROM from the eMac/2002 ROM? As far I know there exist already a ROM mod for the eMac/2004 in this forum.
Logged

zefrenchtoon

  • 64 MB
  • ****
  • Posts: 127
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #32 on: February 05, 2024, 07:55:40 AM »

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
Logged

Jubadub

  • 512 MB
  • *****
  • Posts: 544
  • There is no Mac in OS X
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #33 on: April 09, 2025, 10:43:30 PM »

And the note from macnosy says "The only lost feature may be the ability to debug INITs," which is what I'm trying to do.

I'm late replying to this, but I recently asked the author about the state of INITs for debugging with his tool. The answer is that you still can 100%, fully debug INITs with it, and that ability was never lost.

What he was saying on that thread was that, had he gotten these tools to also run under Classic in OS X, the ability to debug INITs wouldn't work on THAT. Regardless, that September 2021 work for Classic did not complete, so there's no OS X Classic version of MacNosy, The Debugger and CoverTest (collectively known popularly as "Jasik's Debugger"). You gotta native boot into Mac OS 9.2.2 (or earlier), which is what we are all about here over at Mac OS 9 Lives.

(It is also still being sold for 100 USD. I don't think the author will change this condition.)

I was also told that, although the tool wasn't touched for 25 or so years, it was still tweaked here and there since then for a few improvements or tiny fixes.
Logged

ssp3

  • Moderator
  • 1024 MB
  • ******
  • Posts: 1033
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #34 on: May 27, 2025, 06:03:09 AM »

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
Logged
If you're not part of the solution, you're part of the problem.

biggieshellz

  • 8 MB
  • **
  • Posts: 14
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #35 on: May 28, 2025, 05:28:39 PM »

I took another quick look at this.  A few things from last time:

* It looks like the Apple Audio Extension largely duplicates what's already in the System file.  Audio works the same with the Apple Audio Extension removed from the Extensions folder.
* There is a function SndHWUtilitiesLib:FixUpNameRegistrySoundEntries() that looks like it might be the one that's removing the device tree entries for the audio interface.  But the Ghidra decompilation of this function is pretty crap, so I will have to follow Elliot's advice and replace the first instruction with an invalid one (0xffff) which should drop me into MacsBug, so I can follow through it.
* Could the sound driver actually be in the ROM?  Does anyone know what plays the "bong" when the machine powers on?

And as far as basic concepts here, the Mac Mini audio is a simple I2S DAC, plus a couple of GPIO pins.  Unlike many of the other classic Mac audio setups, from what I can tell, there is no hardware volume control, so to get things softer, you'd need to multiply each sample by a factor less than 1 (floating-point math).  It's not just going to be that you get the device tree stuff to match with one of the existing Mac OS 9 drivers.
Logged

biggieshellz

  • 8 MB
  • **
  • Posts: 14
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #36 on: January 29, 2026, 08:23:26 PM »

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

joevt

  • 128 MB
  • ****
  • Posts: 156
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #37 on: January 29, 2026, 10:34:40 PM »

* 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?
I suppose you would look at existing driver code to see how they get their addresses.
It may involve iterating through the device tree to find the device, then looking at the assigned addresses property to get the base address.

It's probably a physical address so you'll need to do a mapping to make sure you have a virtual address that your driver can write to.

Does Apple have sample audio output driver source code? What does the driver for Sheep Shaver look like? They have a PCI sound input device driver. Is it a QuickTime component?

* 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.
Does the GPIO have an interrupt? I suppose the device tree will have the interrupt info. In a screenshot earlier in this thread, the GPIO @67 is a separate device in the device tree. In Open Firmware, you could try reading interrupt related registers of the interrupt controller to see if one of the bits is changed by the GPIO.

Can you connect via telnet to grab the output of dump-device-tree? That will have all the device info, GPIOs, interrupts, etc.

Also, use my DumpNameRegistry app in Mac OS 9 to get the OS 9 view of the device tree.
Logged

dtekle

  • 4 MB
  • **
  • Posts: 5
  • New Member
Re: Taking another shot at onboard audio on a Mac Mini G4?
« Reply #38 on: February 01, 2026, 06:27:40 AM »

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:
« Last Edit: February 03, 2026, 05:50:47 AM by dtekle »
Logged
Pages: 1 [2]   Go Up

Recent Topics