Hacker News new | ask | show | jobs
by brynet 55 days ago
>.. macOS only ever programs CS42L84 to operate at either 48 or 96 kHz, we could only add support for those two sample rates to the Linux driver ..

> However, CS42L42 supports all the other common sample rates, and while the register layout and programming sequence is different, the actual values programmed in for 48 and 96 kHz are the same across both chips. What would happen if we simply took the values for all other sample rates from the CS42L42 datasheet and added those to the CS42L84 driver? As it turns out, you get support for those sample rates!

> The patch to enable hardware support for 44.1, 88.2, 176.4 and 192 kHz sample rates on both the input and output of the headphone jack was submitted directly upstream, and has been merged for 7.1. We also backported this to Asahi kernel 6.19.9, allowing users to take advantage of this immediately.

Nice bit of chip sleuthing and reverse engineering from the Asahi team!

2 comments

The following is actually the most surprising part to me.

> This is quite limiting, as it forces PipeWire to waste CPU cycles (and therefore battery life) on resampling audio streams that are not either 48 or 96 kHz.

So the Asahi team thinks that only supporting 48 or 96 kHz wastes battery life by forcing the software to resample audio streams. But why does Apple still do this? Presumably Apple has a very high commitment to save power and increase battery life.

Always possible that it's the standard commercial software company reason: They do know about it and have a P2 bug tracking it, but the team that maintains that code has 5000 other things to do, and it never gets fixed.
More likely it’s that 48 kHz is a more sensible default, since the majority of non-music digital audio is sampled at 48 kHz, almost anyone who cares about potential audio artifacts introduced by resampling is going to be using an external DAC, and (from an Apple-centric viewpoint) almost anyone concerned about the energy consumption of music playback on their MacBook is going to listen to music on their iPhone instead.
Maybe this is a little pedantic, but we're not talking about a default among the many other available options supported by the chip. We're talking about 48 or 96 kHz being intentionally (or unintentionally) made the only allowed options.

So either someone said "we must disallow the other options" or they didn't and it's a bug.

do we ever get apple engineers rolling thru here or on mastodon? wish stuff like this wasn't such a black box behind the scenes.

i think the only time ive ever run into an apple engineer was on mastodon related to gptk it was interesting to see they actually are quite tuned into what is possible on these devices and what that could mean for gaming. despite being a developer toolkit to help studios get a read on the work needed to optimize a game for a metal port, they were expressing that they were well aware such tools showed a lot of promise for getting games going on mac. not much of a gamer myself, but thought it was interesting to see a slice into engineering there & that they weren't as hostile as HN would believe them to be and broadly aligned with many of us. id be mega curious what apple engineers think about asahi.

We’ve had a few over the years but it’s usually after they’ve left.

E.g, an AppKit engineer or two, or the primary dev behind Rosetta 2. Not so sure of any hardware-engineers tho.

> do we ever get apple engineers rolling thru here or on mastodon? wish stuff like this wasn't such a black box behind the scenes.

Very rarely. I believe because Apple has a culture of secrecy and contractually forbids employees from sharing details about their work in most circumstances (and actually enforces this).

Imagine LCD screen capable of emitting from IR to UV and people up in arms because laptop vendor software limits output to visible spectrum.
I would not agree with your analogy. [0] Turns out the movie industry actually uses infrasound in horror movies. [1] It might also explain why people think old buildings are haunted. [2]

If Apple only focuses on audible sounds, their devices lack the ability to maximize the thrill of horror movies.

[0] https://en.wikipedia.org/wiki/Infrasound

[1] https://nightscapestories.com/the-art-of-sound-design-horror...

[2] https://www.theguardian.com/science/2026/apr/27/spooky-feeli...

Come on, don't do that here. You can see in the thread I replied to there are practical benefits for supporting additional sampling rates.
Likely because the only speakers Apple cares about are Airpods/Airpod max so they are free to only pick the 2 most common sample rates.
Presumably Apple can resample audio streams extremely cheaply.
I mean the algorithms for that are known, and PipeWire/PulseAudio implements them competently. But it still has to be done.
Just like the mouse that has to be polled 100 times per second or display that is composited from all window buffers at least 60 times per second. It might really be negligible in the grand scheme of things and not worth optimizing for.
You cant imagine how much strain fast-moving mouse cursor put on display server of almost any OS if there a lot of windows open simultaneously. Also non-standard cursor sizes / formats are still such a mess everywhere since even in 2026 there are semi-hardware and software cursors...
whoa, bit perfect CD/flac playback in 44.1, that's a killer feature.
There are many audio resampling libraries available that can convert from 44.1 to 48 kHz with no perceptible quality loss. E.g. see

https://github.com/hasenbanck/resampler#quality-analysis

This is presumably what Apple does. You kind of have to anyway or you have the stupid situation Linux used to have where only one app could play audio at a time.

Hardware often reports supporting 44.1kHz but internally resamples it to 48kHz so you're better off properly resampling it yourself.
> you have the stupid situation Linux used to have where only one app could play audio at a time

When was that? I think my first Linux distribution was Ubuntu 8.04 and fairly sure it shipped with PulseAudio which in mind always been able to play audio from multiple sources at the same time, maybe I misremember?

Pure ALSA would behave like that because the currently playing process would take exclusive control of the hardware.

Upsite: Highest quality playback.

Downside: Only one process could play audio at a time.

Only if you had no hardware nor software mixing configured, which probably should be considered a misconfiguration of your system.
ALSA had dmix for some time already, but the default configuration of your distro may not have enabled it.
As I recall it was rarely enabled by default and was a pain to set up so in practice not really used.

The most common solution at the time was PulseAudio, which was so bad it usually was better to just use direct ALSA and live with the idiotic one-at-a-time limitation.

Thankfully Pipewire seems to actually work reliably so I guess that's at least one thing ticked off the Year of the Linux Desktop checklist.

Most distributions shipped ALSA preconfigured with dmix, which means multiple applications could play sound at the same time just fine.

Which is why the whole "we must use pulseaudio even if it's terrible and has awful standards that blast volume or multiple streams won't work!" was so weird… everybody who tried knew that just removing pulseaudio the multiple streams kept working :)

So only those who never applied the scientific method kept insisting that without PA it was not possible to do that.

I think PA allows for setting applications volumes and have a modular design. But it's kinda the poster child of overengineering (challenged by systemd now). Something like sndiod is more sensible for most desktop distro. People that need a more complex setup can bring in the big gun like pipewire.
There was a time when OSS was the only option and ALSA was rarely supported by software. ALSA's dmix also didn't exist from the start.

Around 2000 I was only able to play sound from different apps because my soundcard exposed two sound devices /dev/dsp0 and /dev/dsp1

In the time before PulseAudio, when it was ALSA (and OSS).
Even back then, it could play more than one stream. You had to have a sound card or kernel drivers that supported it (and all non-obsolete ones did by the time pulse audio came out).

I still don’t know what purpose pulseaudio serves, other than adding latency and making stuff less reliable.

PipeWire is better, but it turns out you can just use OSS under freebsd these days, and everything just works, but with lower latency.

If you have some sort of potato sound card that can’t mix output channels in hardware, note that OSS added sw mixing by 2007 (with support for 16 channels by default).

Sure, sure. I remember a time when I didn't have a sound card that supported it and couldn't play multiple streams at a time; this is a thing that really happened. I did eventually go out and buy a soundcard to enable multiple streams.
Nonsense - HDA systems were overwhelmingly the majority of Linux systems at that point, and didn't have any hardware support for multiple streams. OSS with software mixing was a commercial product that wasn't upstream. ALSA had userspace mixing but it was very much not an out of the box experience, and didn't take advantage of hardware capabilities in the way Pulseaudio did to reduce wakeups and power consumption.
If you have two audio streams, you can't play them as is on the audio device, you have to mix them together. The same happens with analog speakers as you can't just add two signals together. I believe at one point with Alsa, when an application takes control of the audio device, no one else could play with it. Now Alsa comes with dmix (a digital mixer feature) enabled in its default configuration, so two applications may play how they want. And we have PulseAudio, Jack, and Pipewire on top of Alsa to add more features.

OpenBSD still present raw audio devices, but they have sndio which provides a more helpful interface for applications including resampling (not the best algorithms there, according to them).

Well, good enough it you read the OpenBSD FAQ section on Multimeda for RT throughput and the like.
Came later I believe. They had esd and other sound “servers” back then however. Might have had to install it yourself.
No its not. You wont be able to hear the difference between 44.1 vs 48.