Fixing intermittent sound problem on an iMac17,1 with fresh install of Linux Mint 21.3

This 27 inch iMac from 2015 worked perfect with Mint.... Except for the sound.
April 6, 2024 by
Andrew Valenzuela
| No comments yet
TLDR:
  • The fix is to add "options snd-hda-intel model=imac27" to the file "/etc/modprobe.d/alsa-base.conf"
  • Various PCs have model specific issues.
  • Learn which models at: https://docs.kernel.org/sound/hd-audio/models.html
  • NO CODE FIX: just buy a usb speaker. Those come with thier own sound cards installed. So you can bypass this whole mess.
Summary:

I go through the troubleshooting steps. Info gathering, Google Fu. And teach you some Linux commands along the way.

The Problem:

The sound appeared to work just fine.  Able to play a YouTube video while doing the setup for my customer.  

Got it to them, and everything works (Linux, "it just works!").  

And then ....  they couldn't play a radio station via the browser.  But could still hear the feedback from some of their programs (e.g. the ding you get when you save an item in quickbooks.).  

Troubleshooting:

When troubleshooting, always do the needful:

  • Gather technical specs about the product.
  • Recognize the problem as stated by the customer; reword the problem using technical terms.

Troubleshooting: How to fix anything.

John DOE • CEO of MyCompany


As with all problems, to effectively troubleshoot.  You have to be able to reliably reproduce the problem.  

Which in this case was a PITA.  Because I could not get the problem to happen for the first 30 minutes of testing.

Then I stumbled onto a way to get the problem to happen consistently.  Download an .mp3 from the net:  FOSS site to download royalty-free music and other media

Open that mp3 using the default media player, Celluloid:

And also use the built-in speaker-test​ command:

The speaker-test command in Linux is used for diagnosing and testing audio systems. It generates sound in various channels, allowing users to verify speaker functionality and audio configurations. This tool is part of the ALSA system, useful for troubleshooting audio issues.

If I played the .mp3​ and ran speaker-test​ in an alternating pattern.  I could get the problem to reproduce.  

Now i have a sure way to reproduce the problem.  And the rest of the troubleshooting can be done.  

The Needful, know what you're working on:

Linux (the Debian based distributions) has this wonderful tool lshw​ (list-hardware).  

Run this command and it will output the hardware info in HTML format and export that to a file on your desktop:  sudo lshw -html > ~/Desktop/myHardwareInfo.html

This will give you the basic info you need.  But we need more specific info about the sound card.  

And for that we will run inxi -A

The inxi​ command in Linux offers a concise overview of the system's hardware and software setup, including CPU, graphics, and network details. It's a go-to tool for quick system diagnostics and information gathering.

Now I know what sound servers we are using.  And that we have two sound cards.  One is controls the internals, including the mic, (Intel 100 ...).  The other controls the sound output for the HDMI connection.  

Turns out that the ppl behing HDMI are anti-FOSS:  https://arstechnica.com/gadgets/2024/02/hdmi-forum-to-amd-no-you-cant-make-an-open-source-hdmi-2-1-driver/
Good thing everyone is moving to USB-C

ALSA runs the bare bones of the sound system.  
And PulseAudio is a server that runs on-top of ALSA.  
PulseAudio manages the sounds being produced by all of the programs on your PC.  And allows you to manage the volume of each sound source.  
PipeWire does the same thing as PulseAudio more or less.  My understanding is that PipeWire is a replacement for Pulse.  But Mint has both running as default.  I am unsure why.

I still need to know some specific info about the sound... (you can never have too much info).

I want to know the codec​ used.  To get that I can run cat /proc/asound/card0/code* | grep Codec​  which may or may not work with your Linux distro.  

Or I can just run aplay -l​ 

Which will list the audio devices and give some basic info about them, including the codec (doesn't always, but in this case its there in the name):

Basic Troubleshooting:

Ok, I've got all the info I could possibly need.  But, this problem could be something as simple as a muted speaker.  

Let's Check:

Maybe its muted on one specific channel.  And that can't be accessed from the GUI.  Let's open the base sound server (ALSA) controls:  alsamixer

This is how to control each channel of the sound system from the terminal through ALSA.

MM​ means that a channel is muted.  And 00​ means it's not muted.

The only thing muted is the Headphone output.  Which makes sense, because I don't have one plugged in...

The basics are out of the way.  Now it's time for Google-Fu

Google-Fu:

Search Terms:

  • sound
  • mac
  • iMac17,1
  • Linux Mint
  • 4206
  • snd_hda_intel

As per usual... it's an endless supply of unsolved forum posts.  

Except that last one!

Link to that solved post.

That's all well and good.  We can run a command and blindly issue a fix.  But, not on someone else's computer.  Plus this is a fix for an older version of Mint.  We are running 21.3

Only blindly run commands on test machines...

More Google Fu:

Search Terms:

  • options snd-hda-intel model=imac27_122

Looks like there is a common fix.  And it's a fix that is for multiple sound problems for various models.  

Solution:

In Linux, everything "just works".... unless it doesn't.  Luckily there is an army of FOSS devs who update the kernel to add fixes for oddball cases.  

In this case there is a fix that is specific to the iMac 27" models that use sound cards which use the CS4206 codec.  

The correct driver loaded, and the auto configuration worked:

FYI, you can get this above text file by running the command alsa-info​ and select the option to "save locally". 

But there's still some quirkiness.  We need to load an option for this module from the kernel.  

Specifically we need to specify the model of PC we are using.  There's a number of options for all of these different models.  Which can all be found in the Linux Kernel Docs:  Linux Kernel Docs, HD-Audo Codec-Specific Models

Search for 4206 (our codec).  

The model I have is an iMac17,1

Which is generically known as a 27" iMac:

So we need to load this option to our alsa-base.conf

Which is located in /etc/modprobe.d

The solutions in the forum posts say to use the command line to add the line we need to add to this config.  I hate doing that.  Because I like to keep notes.  And see what I am editing.  

Linux Mint has this nice context menu option to open a folder as root​ so you can edit files in that folder as root.

Once you open that as root.  You can open the doc.  Edit it and save.  Reboot and test.

After the reboot I tested by using speaker-test​ and playing YouTube and random mp3 files.  It works. 

If this doesn't work for you, try other models listed in the kernel docs.  


Andrew Valenzuela April 6, 2024
Share this post
Tags
Archive
Sign in to leave a comment